0

我有两个查询,我认为应该返回相同数量的结果。首先是在 2 个字段上带有 query_string 的“必须”。例如

{
  "query": {
    "nested": {
      "path": "app.pub",
      "query": {
        "bool": {
          "must": [
            {
              "query_string": {
                "query": "wheel* chair* foot* driven*",
                "fields": [
                  "app.pub.title.*.docdba",
                  "app.pub.abstract.*.docdba"
                ],
                "default_operator": "and"
              }
            }
          ]
        }
      }
    }
  }
}

这给了我 120 个结果。第二个是“应该”查询,在标题字段或摘要上搜索带有通配符的相同字符串。例如:

{
  "query": {
    "nested": {
      "path": "app.pub",
      "query": {
        "bool": {
          "should": [
            {
              "query_string": {
                "query": "wheel* chair* foot* driven*",
                "fields": [
                  "app.pub.title.*.docdba"
                ],
                "default_operator": "and"
              }
            },
            {
              "query_string": {
                "query": "wheel* chair* foot* driven*",
                "fields": [
                  "app.pub.abstract.*.docdba"
                ],
                "default_operator": "and"
              }
            }
          ]
        }
      }
    }
  }
}

在这里,我得到 109 个结果。所以我的点击次数减少了 11 次。有人知道为什么吗?

4

1 回答 1

0

简单的。在第一次搜索中,我在两个字段中寻找 4 个单词。这意味着它匹配在一个字段中不包含所有搜索词的字段,但也匹配两个字段的组合。在第二次搜索中,所有 4 个单词都必须出现在一个字段或另一个字段中。

于 2017-06-07T09:33:41.880 回答