[英]Update a field from a Elasticsearch document
我需要更新索引為 Elasticsearch 的文檔中的一個字段。 我該怎么做。
"redcash_sale": {
"type": "object"
}
將上面的字段更新到下面(使啟用為 false):-
sale_property_development_j/_mapping/property
{
"properties": {
"redcash_sale": {
"type": "object",
"enabled": false
}
}
}
當我再次映射到 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 索引,刪除原始索引,然后使用新映射再次_reindex到原始索引。
重新索引:
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
很高興有解決方案
根據: https://www.elastic.co/guide/en/elasticsearch/reference/current/enabled.html
無法使用 PUT 映射 API 更新已啟用。
然后你必須重新索引你的數據。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.