Update a field from a Elasticsearch document

后端 未结 2 1530
孤城傲影
孤城傲影 2020-12-07 06:37

I need to update a field in the documents indexed to Elasticsearch . How can i do it.

\"redcash_sale\": {
\"type\": \"object\"
}

update ab

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-07 07:12

    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.

    Reindex:

    POST _reindex   
    {
      "source": {
        "index": "sale_property_development_j"
      },
      "dest": {
        "index": "new_sale_property_development_j"
      }
    }
    

    Delete original index:

    DELETE sale_property_development_j
    

    Create requested mapping:

    PUT sale_property_development_j
    {
       "mappings":{
         "property":{
           "properties": {
             "redcash_sale": {
               "type": "object",
               "enabled": false
              }
           }
         }
      }
    }
    

    Reindex again:

    POST _reindex?wait_for_completion=false    
    {
      "source": {
        "index": "new_sale_property_development_j"
      },
      "dest": {
        "index": "sale_property_development_j"
      }
    }
    

    Finally:

    DELETE new_sale_property_development_j
    

    It's a nice to have solution

提交回复
热议问题