{"query": { "bool": { "should": [ {"bool": { "must": [ {} ] } }, {"bool": { "must": [ {} ] }} ] } } }
bool 過濾
bool 過濾可以用來合並多個過濾條件查詢結果的布爾邏輯,它包含一下操作符:
- must :: 多個查詢條件的完全匹配,相當於 and。
- must_not :: 多個查詢條件的相反匹配,相當於 not。
- should :: 至少有一個查詢條件匹配, 相當於 or。
這些參數可以分別繼承一個過濾條件或者一個過濾條件的數組:
{
"bool": {
"must": { "term": { "folder": "inbox" }},
"must_not": { "term": { "tag": "spam" }},
"should": [
{ "term": { "starred": true }},
{ "term": { "unread": true }}
]
}
}