Using preference _local in elasticsearch Using preference _local in elasticsearch elasticsearch elasticsearch

Using preference _local in elasticsearch


Using _local preference in this scenario is fine, since you have two nodes and one replica for your indices, which means each node has exactly the same data.

Preference _local will run the query you are sending to a node, on that particular node's data. If that node doesn't have the data that needs to be queried will send the requests to other nodes, as well.

Also, when querying an Elasticsearch cluster you need to send your search requests either via a client node, or via a load balancer or your code needs to target BOTH nodes. Basically you want all your nodes to perform the "gatherer" job. This is important because the node that receives the search request is the only who gathers the results from all other nodes, performs final searching and aggregations and send the results back to the user. So, the node that gets the request is the one who's doing more work.

In a two-node scenario with preference _local the queries load balancing is even more important because that node that gets the request always will perform all the work, the other one will be idle.