Limit the number of results returned by Elastic Search

I had a problem when I want to reduce the number of Elastic search results to 1000, no matter how many matches match them, but this should not affect the ranking and rating.

I tried terminate_after , but it seems like I just said that an elastic search allows you to get only the best N results, not taking into account the estimates. Correct me if I am wrong.

Any help on this?

EDIT:

I already use pagination. Thus, using size in From / Size only affects the size of the current page. But I want to limit the size of the final results to 1000, and then paginate.

+5
source share
2 answers

How about using From / Size to return the required number of results:

 GET /_search { "from" : 0, "size" : 1000, "query" : { //your query } } 
+1
source

Have you tried using

 terminate_after 

The maximum number of documents to collect for each shard, upon reaching which the request will be completed earlier. If set, the response will have a terminated_early boolean field to indicate whether the request was actually being executed. By default there is no terminate_after.

0
source

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


All Articles