1铐姚、知識點:match query底層會自動轉(zhuǎn)換為term+should/must方式
2、實例剖析
(1)普通match如何轉(zhuǎn)換為term+should
{
"match" : {"title" : "java elasticsearch"}
}
ES會自動給我們轉(zhuǎn)換為如下
{
"bool" : {
"should" : [
{"term" : {"title" : "java"}},
{"term" : {"title" : "elasticsearch"}}
]
}
}
(2)operator:and如何轉(zhuǎn)換為term+must
{
"match" : {
"title" : {
"query" : "java elasticsearch",
"operator" : and
}
}
}
{
"bool" : {
"must" : [
{ "term": { "title": "java" }},
{ "term": { "title": "elasticsearch" }}
]
}
}
(3)minimum_should_match如何轉(zhuǎn)換
{
"match" : {
"title" : {
"query" : "java elasticsearch hadoop spark",
"minimum_should_match" : "75%"
}
}
}
{
"bool" : {
"should" : [
{"term" : {"title" : "java"}},
{"term" : {"title" : "elasticsearch"}},
{"term" : {"title" : "hadoop"}},
{"term" : {"title" : "spark"}}
],
"minimum_should_match" : 3
}
}
若有興趣妥泉,歡迎來加入群椭微,【Java初學者學習交流群】:458430385,此群有Java開發(fā)人員盲链、UI設(shè)計人員和前端工程師蝇率。有問必答,共同探討學習刽沾,一起進步本慕!
歡迎關(guān)注我的微信公眾號【Java碼農(nóng)社區(qū)】,會定時推送各種干貨: