1、知识点:match query底层会自动转换为term+should/must方式
2、实例剖析
(1)普通match如何转换为term+should
{
"match" : {"title" : "java elasticsearch"}
}
ES会自动给我们转换为如下
{
"bool" : {
"should" : [
{"term" : {"title" : "java"}},
{"term" : {"title" : "elasticsearch"}}
]
}
}
(2)operator:and如何转换为term+must
{
"match" : {
"title" : {
"query" : "java elasticsearch",
"operator" : and
}
}
}
{
"bool" : {
"must" : [
{ "term": { "title": "java" }},
{ "term": { "title": "elasticsearch" }}
]
}
}
(3)minimum_should_match如何转换
{
"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开发人员、UI设计人员和前端工程师。有问必答,共同探讨学习,一起进步!
欢迎关注我的微信公众号【Java码农社区】,会定时推送各种干货: