官網(wǎng) : A query that matches documents matching boolean combinations of other queries
簡(jiǎn)單的說(shuō)就是幾種must子眶,filter诵原,should,must_not 這幾種查詢的組合
其中:
- must:有相關(guān)性得分分析 類似and
- filter:無(wú)相關(guān)性得分分析 類似and
- should:有相關(guān)性得分迹缀,類似or
- must_not: 有相關(guān)性得分偎捎,類似not
示例:
get index/ _search
{
"query": {
"bool" : {
"must" : {
"term" : { "user" : "zhao" }
},
"filter": {
"term" : { "sex" : "男" }
},
"must_not" : {
"range" : {
"age" : { "gte" : 10, "lte" : 20 }
}
},
"should" : [
{ "term" : { "tag" : "hi" } },
{ "term" : { "tag" : "elasticsearch" } }
]
}
}
}
如上面的查詢:就是查詢 user匹配"zhao"且sex為"男"且(te個(gè)應(yīng)該匹配“hi”和“elasticsearch”其中一個(gè))并且age 不在 【10,20】這個(gè)區(qū)間的數(shù)據(jù)