问题描述:

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?

网友答案:

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.

相关阅读:
Top