bool过滤查询
可以实现组合过滤查询
格式:
{ "bool": { "must: 0, "should: O, "must not":0}}
must:必须满足的条件---and
should:可以满足也可以不满足的条件--or
must_ not:不需要满足的条件--not
GET /lib5/items/_search
{ "post_filter": {"bool": { "should": [{"term": {"price":25}}, {"term": {"itemID": "id100123"}}],"must_not": {"term":{"price": 30}}}}
}
GET /lib5/items/_search
{"query": {"bool": {"should": [{"term": {"price":25}},{"term": {"itemID": "id100123"}}],"must_not": {"term":{"price": 30}}}}
}
范围查询
GET /lib5/items/_search
{"query": {"bool": {"filter": {"range": {"price": {"gt": 25,"lt": 50}}}}}
}
是否存在
GET /lib5/items/_search
{"query": {"bool": {"filter": {"exists":{ "field":"price"}}}}
}