ES不提供修改索引字段类型的操作,只能新建索引再将数据同步过去。
-
原索引
PUT old_index { "mappings": { "_doc": { "properties": { "create_date": { "type": "data", "format": "yyy-MM-dd ||yyyy/MM/dd" } } } } }
-
新索引
PUT new_index { "mappings": { "_doc": { "properties": { "create_date": { "type": "text" } } } } }
-
同步数据
POST _reindex { "source": { "index": "old_index" }, "dest": { "index": "new_index" } }
-
查询索引
GET new_index/_search
-
删除原索引
DELETE old_index
-
设置别名
POST /_aliases { "actions": [ { "add": { "index": "new_index", "alias": "old_index" } } ] }