Suppose we have the following filtering: field > 0 AND field != value
I am a bit mixed up on the many ways that elasticsearch has to express that filter using the bool query.Consider the following queries:
Query one
"bool":{
"must_not":{
"term":{
"field": value
}
},
"must":{
"range":{
"field":{
"gt":0
}
}
}
}
Query 2:
"bool":{
"must_not":{
"term":{
"field": value
}
},
"filter":{
"range":{
"field":{
"gt":0
}
}
}
}
Query 3
"bool":{
"must":{
"bool":{
"must":{
"range":{
"field":{
"gte":value
}
}
},
"must_not":{
"field":value
}
}
}
}
Do query 1 and 2 mean the same thing? Also although I have seen many examples in the form of the query 3 (bool query inside a must|should|must_not clause), it produces an error when validating the query:
org.elasticsearch.index.query.QueryParsingException: [_na] query malformed, no field after start_object'}
What does this error mean? How is the correct form? And why so many ways to filter results?