gpt4 book ai didi

elasticsearch - elasticsearch中must_not和filter的区别

转载 作者:行者123 更新时间:2023-11-29 02:51:53 25 4
gpt4 key购买 nike

谁能给我解释一下elasticsearch中must_not和filter的区别?

例如这里(取自 elasticsearch definitive guide ),为什么 must_not 不也用于范围?

{
"bool": {
"must": { "match": { "title": "how to make millions" }},
"must_not": { "match": { "tag": "spam" }},
"should": [
{ "match": { "tag": "starred" }}
],
"filter": {
"range": { "date": { "gte": "2014-01-01" }}
}
}
}

具体看this documentation , 在我看来它们是完全一样的:

filter: The clause (query) must appear in matching documents. However unlike must the score of the query will be ignored. Filter clauses are executed in filter context, meaning that scoring is ignored and clauses are considered for caching.

must_not: The clause (query) must not appear in the matching documents. Clauses are executed in filter context meaning that scoring is ignored and clauses are considered for caching. Because scoring is ignored, a score of 0 for all documents is returned.

最佳答案

filter用于匹配的文档需要显示在结果中,而must_not用于匹配的文档不显示在结果中。进一步分析:

过滤器:

  1. 写在Filtercontext .
  2. 不影响成绩得分。
  3. 匹配的查询结果将出现在结果中。
  4. 基于精确匹配,而非部分匹配。

不得:

  1. 它在同一个过滤器上下文中再次写入。
  2. 表示不会影响结果的得分。
  3. 符合此条件的文档不会出现在结果中。
  4. 基于精确匹配。

Tabular comparision

关于elasticsearch - elasticsearch中must_not和filter的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47226479/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com