Inconsistent ranking of results by primary / replica for documents with an equivalent rating

I created an index with one shard and 1 replica. I am running ElasticSearch version 1.0.1 and the cluster has 3 nodes.

I noticed that sometimes the ordering of the results for documents with the same rating depends on whether the same query was executed against the primary vs replica. A request is a compliance request.

For example, when executed against the primary result:

{ "took": 2, "timed_out": false, "_shards": { "total": 1, "successful": 1, "failed": 0 }, "hits": { "total": 2, "max_score": 9.058382, "hits": [ { "_index": "testdocs", "_type": "testdocs", "_id": "132898", "_score": 9.058382 }, { "_index": "testdocs", "_type": "testdocs", "_id": "132888", "_score": 9.058382 } ] } } 

when running against a replica:

 { "took": 1, "timed_out": false, "_shards": { "total": 1, "successful": 1, "failed": 0 }, "hits": { "total": 2, "max_score": 9.058382, "hits": [ { "_index": "testdocs", "_type": "testdocs", "_id": "132888", "_score": 9.058382 }, { "_index": "testdocs", "_type": "testdocs", "_id": "132898", "_score": 9.058382 } ] } } 

Not a change to "_id" in the above result order.

I could not reproduce it with a subset of the documents. I believe this happens when the number of segments in the replica is not the same as the primary. In the above case, the replica has 21 versus 28 in its primary form. However, both have the same number of documents, so the data is consistent.

The question I have is the expected behavior, for example, for documents with the same rating. ES does not provide a default order example: sort by _id? The only way to get around it is to explicitly sort the results using _score and _id, or is there some other parameter that I am missing.

+3
source share

Source: https://habr.com/ru/post/1207587/


All Articles