如何更新elasticsearch字段types

我需要更新弹性search字段types整数长我试过以下的方式,它不工作

curl -XPUT 'http://localhost:9200/testwork/_mapping/message?ignore_conflicts=true' -d ' { "message" : { "properties" : { "status" : {"type" : "long"} } } } ' 

如果尝试不使用ignore_conflicts参数,则会出现错误

 {"error":"MergeMappingException[Merge failed with failures {[mapper [status] of different type, current_type [integer], merged_type [long]]}]","status":400} 

但是在使用ignore_conflicts参数得到响应的时候没有得到错误

 {"acknowledged":true} 

但types没有改变状态字段。 请帮我做这个

如果您有数据存在,则无法更改数据types。

您必须删除索引,使用所需的数据types创build映射,然后重新索引数据。


要重新编制索引,您需要导出和重新导入您的数据 – 有一些工具(扫描和滚动和批量API)可以使其更容易,请参阅重新索引数据 。

另一种方法是创build一个新的索引,然后使用别名 – 即当插入写入最新的索引(可以使用一个具有单一索引的别名),但是当进行查询时,从包含所有相关的别名中读取索引(索引的新版本和旧版本)。