Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Terminate After in elasticsearch

I have the intention to use the Terminate After feature of elasticsearch in order to reduce the result set.

The question is, the documents retrieved when using Terminate After, are ranked among the complete set of documents, or just among the reduced returned set?

like image 412
yannisf Avatar asked Nov 04 '16 13:11

yannisf


1 Answers

Terminate after limits the number of search hits per shard so any document that may have had a hit later could also have had a higher ranking(higher score) than highest ranked document returned since the score used for ranking is independent of the other hits.

So yes the document will be ranked depending upon only the result set returned, but this would not affect how the actual score was calculated which takes into account all the documents.

Wanting a reduced result set and wanting it to be ranked depending on all the hits that may have occurred is a contradiction in itself. Terminate after is generally used for filter type queries where the score of all returned docs is the same so that ranking doesn't matter. For match type queries ES uses pagination so it's already quite efficient and you don't really need to restrict the document set anyways.

like image 88
adityasinghraghav Avatar answered Sep 28 '22 07:09

adityasinghraghav