更新关键字字段的ignore_above

时间:2019-06-20 14:11:10

标签: elasticsearch

现有映射:

"call": {
      "type": "text",
      "norms": false,
      "fields": {
        "keyword": {
          "type": "keyword",
          "ignore_above": 256
        }
      }
    }

更新:

PUT myIndex/_mapping
{
    "properties": {
      "call": {
        "type": "text",
        "fields": {
          "keyword":{
            "type": "keyword",
            "ignore_above": 500
          }
        }
      }
    }
  }

我收到此错误:

  {
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "Mapper for [call] conflicts with existing mapping:\n[mapper [call] has different [norms] values, cannot change from disable to enabled]"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "Mapper for [call] conflicts with existing mapping:\n[mapper [call] has different [norms] values, cannot change from disable to enabled]"
  },
  "status": 400
}

我做错了什么?

1 个答案:

答案 0 :(得分:1)

您还必须在更新中包括“规范”属性。您已在原始映射中将其设置为false。忽略它会导致Elasticsearch尝试将其设置为默认值,这是正确的。禁用后无法启用规范字段。如果需要,您必须创建一个新索引。

这是正确的更新:

PUT myIndex/_mapping
{
    "properties": {
      "call": {
        "type": "text",
        "norms": false,
        "fields": {
          "keyword":{
            "type": "keyword",
            "ignore_above": 500
          }
        }
      }
    }
  }