I am trying to get a query which can return a json which satisfies both conditions of a filtering. I am trying to get a response which has feed containing one field named "test1" and it should also be missing a field "test2", Ive tried the query
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"missing": {
"field": "test2"
},
"exists": {
"field": "test1"
}
}
}
}
}
The above query returns all the fields which has the field "test1" and it also returns feeds which are missing field "test2", I am trying to narrow down the response as I only want feeds satisfying both conditions.
You can combine two or more filters using bool filter:
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": [{
"missing": {
"field": "test2"
}
}, {
"exists": {
"field": "test1"
}
}]
}
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With