在为一个字段创建第一个索引时,我犯了一个错误。我错误地将“整数”数据类型分配为“评级”字段的“字符串”,而不是“整数”数据类型。但是存储在该字段中的数据只是整数。当我尝试计算平均评分聚合时,由于字符串数据类型而引发错误。
- 有没有办法在不重新索引的情况下更改字段的数据类型?
- 如果没有重新索引就不可能,如何删除评级字段并添加具有“整数”数据类型的评级字段?
帮我解决这个问题。
更新
使用以下命令删除了索引中的类型
curl -XDELETE 'http://localhost:9300/feedbacks_16/responses'
删除类型并创建具有相同名称的类型并更改我的评分字段的数据类型并重新索引整个数据。一切都很好,直到重新索引。但是平均查询不起作用。以下是我得到的错误:
{ "error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[2NsGsPYLR2eP9p2zYSnKGQ][feedbacks-16][0]: ClassCastException[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData]}{[2NsGsPYLR2eP9p2zYSnKGQ][feedbacks_16][1]: ClassCastException[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData]}{[pcwXn3X-TceUO0ub29ZFgA][feedbacks_16][2]: RemoteTransportException[[tsles02][inet[/localhost:9300]][indices:data/read/search[phase/query]]]; nested: ClassCastException; }{[pcwXn3X-TceUO0ub29ZFgA][feedbacks_16][3]: RemoteTransportException[[tsles02][inet[/localhost:9300]][indices:data/read/search[phase/query]]]; nested: ClassCastException; }{[2NsGsPYLR2eP9p2zYSnKGQ][feedbacks_16][4]: ClassCastException[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData]}]", "status": 500 }