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

Exists Filter

More info about exists filter is in the official elasticsearch docs

Returns documents that have at least one non-null value in the original field.

Simple example

{
    "constant_score" : {
        "filter" : {
            "exists" : { "field" : "user" }
        }
    }
}

And now the query via DSL:

$existsFilter = new ExistsFilter('user');
$constantScoreQuery = new ConstantScoreQuery($existsFilter);

$search = new Search();
$search->addQuery($constantScoreQuery);

$queryArray = $search->toArray();