WARNING: Version 1.5 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Preference
editPreference
editControls a preference
of which shard replicas to execute the search
request on. By default, the operation is randomized between the shard
replicas.
The preference
is a query string parameter which can be set to:
|
The operation will go and be executed only on the primary shards. |
|
The operation will go and be executed on the primary shard, and if not available (failover), will execute on other shards. |
|
The operation will prefer to be executed on a local allocated shard if possible. |
|
Restricts the search to execute only on a node with
the provided node id ( |
|
Prefers execution on the node with the provided
node id ( |
|
Restricts the operation to the specified shards. ( |
Custom (string) value |
A custom value will be used to guarantee that the same shards will be used for the same custom value. This can help with "jumping values" when hitting different shards in different refresh states. A sample value can be something like the web session id, or the user name. |
For instance, use the user’s session ID to ensure consistent ordering of results for the user:
curl localhost:9200/_search?preference=xyzabc123 -d ' { "query": { "match": { "title": "elasticsearch" } } } '