Reputation: 6236
The below syntax is from 2.2 elastic version and its works fine.
{
"bool" : {
"must" : {
"term" : { "name.first" : "shay" }
},
"filter" : {
"not" : {
"range" : {
"postDate" : {
"from" : "2010-03-01",
"to" : "2010-04-01"
}
}
}
}
}
}
What is the corresponding syntax for not clause for 8.9 version since not is not allowed to use in latest version of elastic. Getting parsing_exception unknown query [not] in 8.9
Upvotes: 0
Views: 25
Reputation: 144
To exclude a filter you can use the must_not
so your search will become as below, also the range
needs to be updated see the docs:
{
"bool" : {
"must" : [
{
"term" : {
"name.first" : "shay"
}
}
],
"must_not": [
{
"range" : {
"postDate" : {
"gt" : "2010-03-01",
"lt" : "2010-04-01"
}
}
}
]
}
}
Upvotes: 0