-
Aivaras Gotovskis authoredAivaras Gotovskis authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Not.md 1.03 KiB
Not Filter
More info about not filter is in the official elasticsearch docs
A filter that filters out matched documents using a query.
Simple example
{
"filtered" : {
"query" : {
"term" : { "name.first" : "shay" }
},
"filter" : {
"not" : {
"range" : {
"postDate" : {
"from" : "2010-03-01",
"to" : "2010-04-01"
}
}
}
}
}
}
And now the query via DSL:
$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();