Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limit the number of results returned by Elastic Search

I am having an issue where i want to reduce the number of results from Elastic search to 1,000 no matter how many matching results are there matching, but this should not affect the ranking and scoring.

I was trying terminate_after, but that seems to just tell the elastic search to just get the top N results without considering the scores. Correct me if am wrong.

Any help on this?

EDIT:

I am already using pagination. So, using Size in From/Size will only affect the size of current page. But i want to limit the size of total results to 1,000 and then pagination on that.

like image 418
RohitWagh Avatar asked Jan 23 '17 09:01

RohitWagh


People also ask

How do I get more than 10 results in Elasticsearch?

If a search request results in more than ten hits, ElasticSearch will, by default, only return the first ten hits. To override that default value in order to retrieve more or fewer hits, we can add a size parameter to the search request body.


1 Answers

How about using From/Size in order to return the requirement number of results:

GET /_search {     "from" : 0, "size" : 1000,     "query" : {         //your query     } } 
like image 77
Kulasangar Avatar answered Sep 23 '22 13:09

Kulasangar