minimum_should_match的默认值?

minimum_should_match的默认值?,第1张

minimum_should_match的默认值?

默认值

minimum_should_match
取决于查询上下文

  • 1
    :在查询上下文中且
    should
    单独存在(否
    must
    filter
  • 1
    :在过滤器上下文中(例如
    filter
    ,在
    bool
    查询的一部分内部;在ES 6.7之前为true)
  • 0
    :在过滤器上下文中(例如
    filter
    ,在
    bool
    查询的一部分内部;自ES 7.0起为true,请参见下面的注释)
  • 0
    :在查询上下文中,有
    must
    and
    should
    (或
    filter
    and
    should

可以在

bool
查询文档中找到:

如果布尔查询位于查询上下文中,并且具有must或filter子句,则文档将与布尔查询匹配,即使没有应当匹配的查询。在这种情况下,这些子句仅用于影响得分。如果布尔查询是一个过滤器上下文,或者既没有必须查询也没有过滤器,则应该查询中的至少一个必须与文档匹配才能使其与布尔查询匹配。可以通过设置minimum_should_match参数来明确控制此行为。

一些例子

查询上下文,并且

should
是单独的:

POST _search{  "query": {    "bool" : {      "should" : [        { "term" : { "tag" : "wow" } },        { "term" : { "tag" : "elasticsearch" } }      ]      # default:      # "minimum_should_match" : 1    }  }}

查询上下文,

must
并与
should

POST _search{  "query": {    "bool" : {      "must" : {        "term" : { "user" : "kimchy" }      },      "should" : [        { "term" : { "tag" : "wow" } },        { "term" : { "tag" : "elasticsearch" } }      ]      # default:      # "minimum_should_match" : 0    }  }}

过滤器上下文:

POST _search{  "query": {    "bool": {      "filter": {        "bool": {          "must": { "term" : { "user" : "kimchy" }          },          "should": [ { "term" : { "tag" : "wow" } }, { "term" : { "tag" : "elasticsearch" } }          ]          # default (until ES 6.7):          # "minimum_should_match" : 1        }      }    }  }}
更新:与ES 7.0相关的更改

在Elasticsearch
7.0中,过滤器上下文已被删除,这实际上意味着在过滤器上下文中其默认值现在为

0



欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/4936138.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-13
下一篇2022-11-13

发表评论

登录后才能评论

评论列表(0条)

    保存