Skip to content
Snippets Groups Projects
Commit ac05db95 authored by Aivaras Gotovskis's avatar Aivaras Gotovskis
Browse files

Add and filter doc.

parent c319efab
No related branches found
No related tags found
No related merge requests found
# And Filter
> More info about and filter is in the [official elasticsearch docs][1]
A filter that matches documents using the AND boolean operator on other filters.
Can be placed within queries that accept a filter.
## Simple example
```JSON
{
"filtered" : {
"query" : {
"term" : { "name.first" : "shay" }
},
"filter" : {
"and" : [
{
"range" : {
"postDate" : {
"from" : "2010-03-01",
"to" : "2010-04-01"
}
}
},
{
"prefix" : { "name.second" : "ba" }
}
]
}
}
}
```
And now the query via DSL:
```php
$rangeFilter = new RangeFilter('postDate', ['from' => '2010-03-01', 'to' => '2010-04-01']);
$prefixFilter = new PrefixFilter('name.second', 'ba');
$andFilter = new AndFilter([$rangeFilter, $prefixFilter]);
$termQuery = new TermQuery('name.first', 'shay');
$search = new Search();
$search->addQuery($termQuery);
$search->addFilter($andFilter);
$queryArray = $search->toArray();
```
[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-and-filter.html
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment