Search results order varies each time in Elasticsearch


(banupriya) #1

We have 200k records. When running search query for the first time with size: 500 I am getting results in doc-1, doc-2, doc-3. But when I run the same search query for the second time I am getting the order changed to doc-2, doc-1, etc ... why the search result order varies each time when we run the same query ?


(Isabel Drost-Fromm) #2

Without knowing the mapping, query and content of your index it's rather hard to guess at what's going on there.

Did you try using the explain API:

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html

To figure out why your documents are sorted the way they are sorted?

Other than that, maybe you can come up with a minimal curl reproduction of your problem that doesn't involve first indexing 200k documents so others can have a look...

Hope this helps,
Isabel


(Mark Walkom) #3

Response order is not guaranteed in searches as far as I understand. It returns results in terms of scoring.


(system) #4