Update a field from a Elasticsearch document

后端 未结 2 1521
孤城傲影
孤城傲影 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:08

    According to: https://www.elastic.co/guide/en/elasticsearch/reference/current/enabled.html

    Enabled cant be updated using the PUT mappings API.

    You have to reindex your data then.

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题