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
  }
}



转自于:https://www.jianshu.com/p/3c4f98bffb34

相关文章:

  • 2021-05-22
  • 2021-12-02
  • 2021-05-14
  • 2021-06-01
猜你喜欢
  • 2021-06-26
  • 2021-11-20
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2018-11-24
相关资源
相似解决方案