Elasticsearch paging when results have equal scores

Is it possible to implement a reliable search for elasticsearch search results if multiple documents have the same score?

I am experimenting with custom counting in elasticsearch. Many of the expressed expression factors that I am trying to get give result sets where many documents have the same ratings. They seem to come in the same order every time I try, but can this be guaranteed?

AFAIU it cannot, especially if there is no more than one fragment in a cluster. Documents with an equal score on. the specified elasticsearch request is returned in a random, non-deterministic order, which can change between calls to the same request, even if the underlying database does not change (and therefore the paging is unreliable) if one of the following conditions is not met:

  • I use function_score to ensure that the score is unique for each document (for example, using a unique number field).
  • I use sort and guarantee that sorting determines the general order (for example, using a unique field as a reserve if everything else is equal).

Can someone confirm (and possibly point to some link)?

Is this a change if I know that there is only one primary splinter without any replicas (see another similar querstion: Inconsistent ranking of results by primary / replica for documents with an equivalent rating )? For instance. if I guarantee that there is one fragment And there are no changes in the database between two calls of the same query, then this query will return the results in the same order?

What other alternatives (if any)?

+5
source share
1 answer

As a result, I used an additional variety in cases where equal points are likely - for example, search by product category. This additional view may be id, creation date or similar. Setup - 2 servers, 3 shards and 1 replica.

+1
source

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


All Articles