首页 > 解决方案 > simple_query_string 搜索中的多个单词短语不返回突出显示数据,但会返回任何非零斜率

问题描述

使用 simple_query_string 和任何荧光笔(普通、统一、fvh)时,我会出现一种特殊的高亮行为

  1. 简单查询字符串使用术语(不是短语) 时工作的亮点:仅使用术语时工作

  2. 当您关闭引用时,亮点停止工作,有效地使定期会议成为一个短语: 作为短语搜索时根本不起作用

  3. 但是,如果我在以前不工作的短语中添加任何超过 0 的 slop,它会再次正常工作,尽管结果集错误,因为我不想要 slopped 结果: 如果我 slop 但是效果很好

当使用直接 API 请求时,当搜索具有零斜率(或斜率未定义)的短语时,突出显示键在结果中完全消失,导致上述第二步中的行为。

我也尝试过覆盖突出显示查询,同样的问题。这是我在这些示例中使用的查询,我还使用硬编码字符串和 API 调用直接复制了这种行为:

        "query": {
          "simple_query_string": {
            "query": query,
            "fields": ["title", "content"]
          }
        },
        "highlight": {
          "fields": {
            "title": {},
            "content": {}
          }
        }

突出显示的相关字段(标题、内容)具有如下映射:

"properties" : {
    "content" : {
      "type" : "text",
      "fields" : {
        "autosuggest" : {
          "type" : "text",
          "analyzer" : "autosuggest_analyzer",
          "search_analyzer" : "ngram_search_analyzer"
        },
        "delimiter" : {
          "type" : "text",
          "index_options" : "offsets",
          "analyzer" : "universal_delimiter_analyzer"
        },
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        },
        "lang" : {
          "type" : "text",
          "analyzer" : "universal"
        },
        "synonyms" : {
          "type" : "text",
          "analyzer" : "synonyms"
        }
      },
      "analyzer" : "standard",
      "index_prefixes" : {
        "min_chars" : 1,
        "max_chars" : 12
      },
      "index_phrases" : true
    },
    "title" : {
      "type" : "text",
      "fields" : {
        "autosuggest" : {
          "type" : "text",
          "analyzer" : "autosuggest_analyzer",
          "search_analyzer" : "ngram_search_analyzer"
        },
        "delimiter" : {
          "type" : "text",
          "index_options" : "offsets",
          "analyzer" : "universal_delimiter_analyzer"
        },
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        },
        "lang" : {
          "type" : "text",
          "analyzer" : "universal"
        },
        "synonyms" : {
          "type" : "text",
          "analyzer" : "synonyms"
        }
      },
      "analyzer" : "standard",
      "index_prefixes" : {
        "min_chars" : 1,
        "max_chars" : 12
      },
      "index_phrases" : true
    },
    ...

最后,这是版本信息:

  "version" : {
    "number" : "7.9.0",
    "build_flavor" : "oss",
    "build_type" : "rpm",
    "build_hash" : "a479a2a7fce0389512d6a9361301708b92dff667",
    "build_date" : "2020-08-11T21:36:48.204330Z",
    "build_snapshot" : false,
    "lucene_version" : "8.6.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },

有没有人遇到过这个?我在这里遗漏了什么明显的东西吗?这很令人困惑,因为它可以很好地与 slop 配合使用,但否则甚至不会在结果中返回突出显示条目。到目前为止,我所见过的任何其他问题/解决方案似乎都与此问题无关。

标签: elasticsearchluceneaws-elasticsearch

解决方案


推荐阅读