Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.

Limit Filter

More info about limit filter is in the official elasticsearch docs

A limit filter limits the number of documents (per shard) to execute on.

Simple example

{
    "filtered" : {
        "filter" : {
             "limit" : {"value" : 100}
         },
         "query" : {
            "term" : { "name.first" : "shay" }
        }
    }
}

And now the query via DSL:

$limitFilter = new LimitFilter(100);
$termQuery = new TermQuery('name.first', 'shay');

$filteredQuery = new FilteredQuery($termQuery, $limitFilter);

$search = new Search();
$search->addQuery($filteredQuery);
$queryArray = $search->toArray();