June 2017
Beginner to intermediate
404 pages
8h 22m
English
A query can be answered by a primary or a replica shard as they are exact copies. Query requests are usually round robin between primary and replica shards. Since the request is first executed on the primary shard and then forwarded to the replicas, there may be a time when the data from the primary is different from the replica. If your application always needs the latest data, you can use the preference property to control which shard the request is executed on.
Let's consider the following example:
POST chapter4/person/_search?preference=_primary { "query": { "match": { "name": "user1" } } }
The preceding request will be executed only on the primary shards. The other option is _primary_first. The request is executed ...
Read now
Unlock full access