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
}
}
}
raising error when I do mapping again to elasticsearch:-
Error
{
"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
}
thanks in advance!
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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.