当术语包含括号时,嵌套内部命中没有突出显示

No highlights from nested inner hit when term contains brackets

我有一个包含嵌套字段的文档,但我在突出显示时遇到了一些问题。当我的术语查询包含尖括号 (<>) 时,为什么我没有突出显示?

我们在包含相似数据的嵌套映射中有两个字段:

"value": {
  "type": "keyword",
  "normalizer": "lowercase"
},
"valueWithQualifier": {
  "type": "keyword",
  "normalizer": "lowercase"
}

lowercase 标准化器使用过滤器 ["asciifolding", "lowercase"]

value 通常是字母数字字符串,但 valueWithQualifier 采用 value<qualifier> 的形式。当我在 value 字段上执行术语查询时,它通常会 return 突出显示信息。当我在 valueWithQualifier 字段上执行术语查询时,我从来没有得到突出显示的信息。

{
  "query": {
    "nested": {
      "path": "assoc",
      "query": {
        "term": {
          "assoc.value": "123abc"
        }
      },
      "inner_hits": {
        "highlight": {
          "fields": {
            "assoc.value*": {}
          }
        }
      }
    }
  }
}

这 return 是一个内在的亮点:

"highlight": {
  "assoc.value": [
    "<em>123abc</em>"
  ]
}

但是,此查询 returns inner_hit 但没有突出显示:

{
  "query": {
    "nested": {
      "path": "assoc",
      "query": {
        "term": {
          "assoc.valueWithQualifier": "123abc<qual>"
        }
      },
      "inner_hits": {
        "highlight": {
          "fields": {
            "assoc.value*": {}
          }
        }
      }
    }
  }
}

但是,这会 return 突出显示(但出于效率考虑,我宁愿使用术语查询):

{
  "query": {
    "nested": {
      "path": "assoc",
      "query": {
        "prefix": {
          "assoc.valueWithQualifier": "123abc"
        }
      },
      "inner_hits": {
        "highlight": {
          "fields": {
            "assoc.value*": {}
          }
        }
      }
    }
  }
}

"highlight": {
  "assoc.valueWithQualifier": [
    "<em>123abc<qual></em>"
  ]
}

在有人问之前,我已经尝试将 "encoder": "html" 添加到突出显示。

事实证明这是一个在 ES 6.2 (https://github.com/elastic/elasticsearch/pull/27604) 中修复的错误。