Elasticsearch 6.3 字段类型变化,重建索引的方案

业务组现在有个需求是,某个字段类型是 “keyword”,现在要改为“text”类型。

可以直接采用reindex 方案,不需要Client 端重写数据。

样例如下

定义一个 twitter1 索引 mapping

PUT twitter1
{
    "mappings" : {
        "type1" : {
            "properties" : {
                "field1" : { "type" : "keyword" }
            }
        }
    }
}

put 数据

PUT twitter1/type1/1
{
    "field1" :  "I like to build cabinets"
}

将field1字段类型”keyword” 改为 “text”,须新建索引

PUT twitter1_new
{
    "mappings" : {
        "type1" : {
            "properties" : {
                "field1" : { "type" : "text" }
            }
        }
    }
}

reindex

POST _reindex
{
  "source": {
    "index": "twitter1"
  },
  "dest": {
    "index": "twitter1_new"
  }
}

你可能感兴趣的:(大数据,elasticsearch,工作实践)