Here, I am trying to add datefield. earlier i created the date field as text field but, now when i am trying to change to date field i am getting below error.
{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "mapper [metadata.modifiedAt] cannot be changed from type [text] to [date]"
}
],
"type" : "illegal_argument_exception",
"reason" : "mapper [metadata.modifiedAt] cannot be changed from type [text] to [date]"
},
"status" : 400
}
Please check the screenshot attached.
Thanks,
CodePudding user response:
You can't change the field data type, you have to create a new field. Changing field type is a breaking change, but you can add a new date field in your index.
CodePudding user response:
It's not possible to change the field type but you can add a new field to the existing index.
PUT index_name/_mapping
{
"properties": {
"metadata.modifiedAt_new": {
"type": "date"
}
}
}
After adding the new field the new documents will have the metadata.modifiedAt_new
field as a date field type.
To update existing documents you can run the following API. It will update the whole existing documents.
POST index_name/_update_by_query?conflicts=proceed