首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >弹性搜索minimum_should_match

弹性搜索minimum_should_match
EN

Stack Overflow用户
提问于 2022-09-16 16:01:32
回答 1查看 34关注 0票数 0

为了更好地理解API,我正在分析一些弹性搜索查询,我对这些查询感到困惑。

代码语言:javascript
复制
"query": {
        "function_score": {
            "query": {
                "bool": {
                    "must": {
                        "match": {
                            "title_normalized": {
                                "query": "here goes the query",
                                "minimum_should_match": 2
                            }
                        }
                    },
                    "filter": ...
                },
            },
        },
}

在这种情况下,minimum_should_match有什么意义?没有应该子句,但我们在一个匹配子句中。

同样,这里

代码语言:javascript
复制
"query": {
        "function_score": {
            "query": {
                "bool": {
                    "must": ...
                    "filter": {
                        "bool": {
                            "should": [{
                                "match": {
                                    "title_normalized": {
                                        "query": "here goes",
                                        "minimum_should_match": 2
                                    }
                                }
                            }, {
                                "match": {
                                    "title_normalized": {
                                        "query": "the query",
                                        "minimum_should_match": 2
                                    }
                                }
                            }],
                            "minimum_should_match": 1
                        }
                    }
                },
            },
        },
}

我理解"minimum_should_match": 1在与should相同的缩进级别,但是嵌套在match子句中的minimum_should_match又如何呢?这是什么意思?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-09-16 20:05:27

" match“子句中"minimum_should_match”的使用决定了要匹配的术语的最小数目。例:您有文档“来查询”,您的查询是:

代码语言:javascript
复制
   "match": {
      "title_normalized": {
        "query": "here goes",
        "minimum_should_match": 2
      }
    }

您将检索文档,因为有两个匹配项。

如果将"minimum_should_match“更改为3,则不会有结果,因为匹配项的最小值为3,而查询只有2。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73747521

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档