从 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"
}
将上面的字段更新到下面(使启用为假):-
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到一个dest索引,删除你原来的,然后_reindexstrong> 再次使用新映射返回到您的原始映射.
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屋!
查看全文