更新Elasticsearch文档中的字段 [英] Update a field from a Elasticsearch document
本文介绍了更新Elasticsearch文档中的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要更新索引到Elasticsearch的文档中的字段。我该怎么做。
I need to update a field in the documents indexed to Elasticsearch . How can i do it.
"redcash_sale": {
"type": "object"
}
将上方字段更新为下方(使为false):-
update above field to below (make enable false) :-
sale_property_development_j/_mapping/property
{
"properties": {
"redcash_sale": {
"type": "object",
"enabled": false
}
}
}
当我再次映射到elasticsearch时引发错误:-
raising error when I do mapping again to elasticsearch :-
错误
{
"error": {
"root_cause": [
{
"type": "mapper_exception",
"reason": "Can't update attribute for type [_doc.redcash_sale.enabled] in index mapping"
}
],
"type": "mapper_exception",
"reason": "Can't update attribute for type [_doc.redcash_sale.enabled] in index mapping"
},
"status": 500
}
预先感谢!
推荐答案
可以做什么要做的是将您的数据 _reindex 为目标索引,删除原始索引,然后使用新的映射再次 _reindex 为原始索引。
What you can do is to _reindex your data to a dest index, delete your original one and then _reindex again to your original one with the new mapping.
重新索引:
POST _reindex
{
"source": {
"index": "sale_property_development_j"
},
"dest": {
"index": "new_sale_property_development_j"
}
}
删除原始索引:
DELETE sale_property_development_j
创建请求的映射:
PUT sale_property_development_j
{
"mappings":{
"property":{
"properties": {
"redcash_sale": {
"type": "object",
"enabled": false
}
}
}
}
}
再次重新索引:
POST _reindex?wait_for_completion=false
{
"source": {
"index": "new_sale_property_development_j"
},
"dest": {
"index": "sale_property_development_j"
}
}
最后:
DELETE new_sale_property_development_j
很高兴有一个解决方案
这篇关于更新Elasticsearch文档中的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文