Elasticsearch在索引模板中使用两个映射抛出错误

问题描述 投票:1回答:1

如果我定义索引模板文件template.json如下:

{
    "template": "types",
    "mappings": {
        "type1": {
            "properties": {
                "title": {
                    "type": "text"
                }
            }
        },
        "type2": {
            "properties": {
                "title": {
                    "type": "keyword"
                }
            }
        }
    }
}

并尝试发布它:

curl -XPUT http://localhost:9200/_template/types [email protected]

我收到了这个回复:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "mapper [title] cannot be changed from type [keyword] to [text]"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "mapper [title] cannot be changed from type [keyword] to [text]"
  },
  "status" : 400
}

我希望能够在模板中定义具有不同类型的不同字段的多个映射。

我在做什么或假设不正确?

我正在使用Elasticsearch 5.6。

elasticsearch elasticsearch-5
1个回答
3
投票

如果字段具有相同的名称,则它们必须具有相同的字段类型,即使您使用的是版本5.6,这是允许在同一索引中使用多个映射类型的最后一个版本。

如果title类型中的字段type1被映射为text,则title类型中的字段type2也需要映射为text

© www.soinside.com 2019 - 2024. All rights reserved.