Skip to content
Snippets Groups Projects
user avatar
Mantas Varatiejus authored
30fb9aef
History
Code owners
Assign users and groups as approvers for specific file changes. Learn more.

Query

Objective filter builder represents all available Elasticsearch filters.

To form a filtered query you have to create Search object. See below an example of match all filter usage.

$search = new Search();
$matchAllFilter = new MatchAllFilter();
$search->addFilter($matchAllFilter);
$queryArray = $search->toArray();

Filters handles are necessary little things like where to put \stdClass and where to simple array. So by using DSL builder you can be always sure that it will form a correct query.

Here's $queryArray var_dump:

//$queryArray content
'query' => [
        'filtered' => [
            'filter' => [
                'match_all' => \stdClass(),
            ]
        ]
    ]

For more information how to combine search queries take a look at How to search chapter.

Filters: