elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
1.02k stars 24.83k forks source link

Pinyin highlight exceptions when field type is array #91495

Open wangkunmeng opened 1 year ago

wangkunmeng commented 1 year ago

Elasticsearch Version

7.8

Installed Plugins

pinyin

Java Version

bundled

OS Version

Darwin bogon 21.6.0

Problem Description

ES Version 7.8

exception

{
  "error" : {
    "root_cause" : [
      {
        "type" : "string_index_out_of_bounds_exception",
        "reason" : "begin 42, end 23, length 49"
      }
    ],
    "type" : "search_phase_execution_exception",
    "reason" : "all shards failed",
    "phase" : "query",
    "grouped" : true,
    "failed_shards" : [
      {
        "shard" : 0,
        "index" : "wangkm_test",
        "node" : "t1U_Sq-nScuDFuLWnMiq_Q",
        "reason" : {
          "type" : "string_index_out_of_bounds_exception",
          "reason" : "begin 42, end 23, length 49"
        }
      }
    ],
    "caused_by" : {
      "type" : "string_index_out_of_bounds_exception",
      "reason" : "begin 42, end 23, length 49",
      "caused_by" : {
        "type" : "string_index_out_of_bounds_exception",
        "reason" : "begin 42, end 23, length 49"
      }
    }
  },
  "status" : 500
}

Steps to Reproduce

Settings And Request

DELETE wangkm_test
PUT wangkm_test
{
  "mappings" : {
    "dynamic" : "false",
    "properties" : {
      "id" : {
        "type" : "keyword"
      },
      "replyContents" : {
        "type" : "text",
        "analyzer" : "ik_max_word",
        "fields" : {
          "pinyin" : {
            "type" : "text",
            "analyzer" : "ik_pinyin_analyzer",
            "search_analyzer" : "standard"
          }
        }
      }
    }
  },
  "settings" : {
        "analysis" : {
          "filter" : {
            "pinyin_filter" : {
              "lowercase" : "true",
              "trim_whitespace" : "true",
              "type" : "pinyin",
              "keep_full_pinyin" : "true"
            }
          },
          "analyzer" : {
            "ik_pinyin_analyzer" : {
              "filter" : "pinyin_filter",
              "type" : "custom",
              "tokenizer" : "ik_max_word"
            }
          }
        }
      }
}

PUT wangkm_test/_doc/1
{
  "replyContents" : [
    "你说的都是啥,产品不认真做",
    "再回复一夏天",
    "测试测试",
    "测测测侧测试的",
    "Fankui",
    "提交一个新的反馈"
  ]
}

GET wangkm_test/_doc/1

GET wangkm_test/_search?ignore_unavailable=true
{
  "query": {
    "bool": {
      "must": [
        {
          "multi_match": {
            "query": "shi",
            "fields": [
              "replyContents",
              "replyContents.pinyin"
            ]
          }
        }
      ]
    }
  },
  "highlight": {
    "fields": {
      "replyContents*": {}
    }
  }
}

Logs (if relevant)

No response

wangkunmeng commented 1 year ago

Elasticsearch Version 8 same result

elasticsearchmachine commented 1 year ago

Pinging @elastic/es-search (Team:Search)

elasticsearchmachine commented 3 months ago

Pinging @elastic/es-search-relevance (Team:Search Relevance)