Elasticsearch 在突出显示中删除字母

Elasticsearch Dropping Letters in Highlight

我有一个 Elasticsearch 索引,当将突出显示应用于搜索时,它会从字段中删除字符。

示例:

GET /myindex/_search
{
  "query": {
    "bool": {
      "must": {
        "multi_match": {
          "query": "greene and associates",
          "fuzziness" : "AUTO",
          "fields": [
            "name"
          ]
        }
      }
    }
  },
  "highlight" : {
        "fields" : {
            "name" : {}
        }
    }
}

Returns 以下:

{
     "_index" : "myindex",
         ...       
      "name" : "A. A. Greene & Associates",
      ... 
     },
     "highlight" : {
       "name" : [
         "<em>Greene</em> & <em>Associates</em>"
       ]
     }
}

我希望结果是

{
      "_index" : "myindex",
          ...       
       "name" : "A. A. Greene & Associates",
        ... 
      },
      "highlight" : {
        "name" : [
          "A. A. <em>Greene</em> & <em>Associates</em>"
        ]
      }
}

我在这个查询中有什么错误?无论我尝试什么,我都无法让 "A. A." 在突出显示结果中返回。

我们是 运行 v7.4,我已经搜索过其他有这个问题的人,但还没有找到任何东西。

这是为索引定义字段的方式:

"name" : {
          "type" : "text",
          "boost" : 3.0,
          "fields" : {
            "raw" : {
              "type" : "keyword"
            },
            "suggest" : {
              "type" : "completion",
              "analyzer" : "simple",
              "preserve_separators" : true,
              "preserve_position_increments" : true,
              "max_input_length" : 50
            }
          }
        }

我找到了我丢失的东西。默认荧光笔是统一荧光笔,它将文本分成句子(名称中的句点符合条件)。 我将荧光笔类型更改为 Plain,它按预期工作。

新查询:

GET /myindex/_search
{
  "query": {
    "bool": {
      "must": {
        "multi_match": {
          "query": "greene and associates",
          "fuzziness" : "AUTO",
          "fields": [
            "name"
          ]
        }
      }
    }
  },
  "highlight" : {

        "fields" : {
            "name" : {"type" : "plain"}

        }
    }
}