I have an index users with user type. Mapping is dynamic. For now user hs a following structure:
"user": {
"nested": {
"one":51
},
"other": {
"two":"hi!"
},
"three":false
}
I need to find all users which has other.two field with value hi or has three field with value false. E.g. user which has other.two must have hi value in it or three field with value false. How to select this from elastic search?
I have tried:
GET /users/user/_search
{"query": {"match": {"other.two": "hi"}}}
Returns a user for me, but
GET /users/user/_search
{"query": {"match": {"other.two": "hi", "three":false}}}
Returns me a SearchPhaseExecutionException.
How combine several fields and values for searching?
As @rvheddeg suggested above, here is the query that works for me:
{
"query": {
"bool": {
"should": [
{ "match": { "other.two": "hi" }},
{ "match": { "three": false }}
],
"minimum_should_match": 1
}
}
}
Use a Bool filter or Bool Query
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