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

Add not filter doc.

parent 96a62718
No related branches found
No related tags found
No related merge requests found
# Not Filter
> More info about not filter is in the [official elasticsearch docs][1]
A filter that filters out matched documents using a query.
## Simple example
```JSON
{
"filtered" : {
"query" : {
"term" : { "name.first" : "shay" }
},
"filter" : {
"not" : {
"range" : {
"postDate" : {
"from" : "2010-03-01",
"to" : "2010-04-01"
}
}
}
}
}
}
```
And now the query via DSL:
```php
$rangeFilter = new RangeFilter(
'postDate',
[
'from' => '2010-03-01',
'to' => '2010-04-01',
]
);
$notFilter = new NotFilter($rangeFilter);
$termQuery = new TermQuery('name.first', 'shay');
$filteredQuery = new FilteredQuery($termQuery, $notFilter);
$search = new Search();
$search->addQuery($filteredQuery);
$queryArray = $search->toArray();
```
[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-not-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