且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

更新Elasticsearch文档中的字段

更新时间:2023-02-21 23:30:05

可以做什么要做的是将您的数据 _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

很高兴有一个解决方案