首页 > 解决方案 > Elasticsearch 更新 ignore_above 给出非法参数异常

问题描述

我正在尝试更新ignore_above我的索引中的值。我正在使用 PUT 到/_mappings/my_type(测试仪)的身体,如下所示:

{
 "properties": {
  "message.keyword": {
    "type": "keyword",
    "ignore_above": 20 
  }
 }
}

它返回:"illegal_argument_exception","reason": "mapper [message] of different type, current_type [text], merged_type [ObjectMapper]"

关于如何解决这个问题的任何想法都会非常好。

这是我的映射:

"mappings": {
        "tester": {
            "properties": {
                "message": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                },

标签: elasticsearch

解决方案


从错误看来,“消息”字段是“文本”数据类型,表示分析的文本,而不是 Json 对象/映射。

当您尝试为“message.keyword”设置映射时,您将消息称为对象,这就是问题所在。

您需要将“消息”更改为多字段,以便同时拥有关键字和文本版本。


推荐阅读