Elasticsearch conditional filter
If I understood, is that?if type == a, all documents that have a will return.And if type == b and the field foo is not there they will return, make sense?
{ "query": { "filtered": { "query": { "match_all": {} }, "filter": { "bool": { "should": [ { "term": { "type": "a" } }, { "bool": { "must": [ { "term": { "type": "b" } } ], "must_not": [ { "missing": { "field": "foo" } } ] } } ] } } } }}