elasticsearch - Combining and with or conditions -
i stuck query has combine conditions.
this properties of catalog following
- _id:integer
- parentid: integer
- path: string
- level: integer
i have absolutely no clue how combine them, query returns need.
- a) _id has 1 of given list (
"_id": ["7","10"]
) or - b) parentid has of given integer (
"_parentid": "1"
) or - c) path has match special pattern (
"regexp": {"path": "/foobar.*"}
) , level has between 2 integer ("range": {"level": {"gte": 2, "lte": 3 } }
)
additionaly entries have 1 defined catalog
i not write down attempts. tried use bool query must , should, not apply c):
{ "query": { "filtered": { "filter": { "bool": { "must": [ { "type": { "value": "category" } } ], "should": [ { "regexp": { "path": "/foobar.*" } }, { "range": { "level": { "gte": 2, "lte": 3 } } }, { "term": { "_id": [ "7", "10" ] } } ] } } } } }
what best way combine , and or conditions? kind of lost.
i think should pretty darn close need.
get devdev/alert/_search { "filter": { "or": { "filters": [ { "terms": { "_id": [ "eee75ejprua4hasvzz0pea", "value2" ] } }, { "term": { "_parentid": "se.se.0000" } }, { "and": { "filters": [ { "term": { "regexp": "foobar" } }, { "range": { "level": { "from": 2, "to": 3 } } } ] } } ] } } }
Comments
Post a Comment