Limit the number of results returned by Elastic Search

RohitWagh picture RohitWagh · Jan 23, 2017 · Viewed 37.5k times · Source

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.

Answer

Kulasangar picture Kulasangar · Jan 23, 2017

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

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