Hi,
I've been testing the new features in the Elasticsearch 7.13, and I have a problem to deleting a field mapping script.
This is my mapping:
PUT runtime_2_indexed_field
{
"mappings": {
"properties": {
"dataNascimento": {
"type": "date"
},
"idade": {
"type": "long",
"script": "emit(Period.between(doc['dataNascimento'].value.toLocalDate(),Instant.ofEpochMilli(System.currentTimeMillis()).atZone(doc['dataNascimento'].value.getZone()).toLocalDate()).getYears())"
}
}
}
}
After I add this document:
POST runtime_2_indexed_field/_doc/1
{
"dataNascimento": "1991-06-01"
}
But when I try to delete this document, it's return this error:
{
"error" : {
"root_cause" : [
{
"type" : "script_exception",
"reason" : "runtime error",
"script_stack" : [
"org.elasticsearch.index.fielddata.ScriptDocValues$Dates.get(ScriptDocValues.java:149)",
"org.elasticsearch.index.fielddata.ScriptDocValues$Dates.getValue(ScriptDocValues.java:143)",
"emit(Period.between(doc['dataNascimento'].value.toLocalDate(),Instant.ofEpochMilli(System.currentTimeMillis()).atZone(doc['dataNascimento'].value.getZone()).toLocalDate()).getYears())",
" ^---- HERE"
],
"script" : "emit(Period.between(doc['dataNascimento'].value.toLocalDate(),Instant.ofEpochMilli(System.currentTimeMillis()).atZone(doc['dataNascimento'].value.getZone()).toLocalDate()).getYears())",
"lang" : "painless",
"position" : {
"offset" : 41,
"start" : 0,
"end" : 183
}
}
],
"type" : "mapper_parsing_exception",
"reason" : "Error executing script on field [idade]",
"caused_by" : {
"type" : "script_exception",
"reason" : "runtime error",
"script_stack" : [
"org.elasticsearch.index.fielddata.ScriptDocValues$Dates.get(ScriptDocValues.java:149)",
"org.elasticsearch.index.fielddata.ScriptDocValues$Dates.getValue(ScriptDocValues.java:143)",
"emit(Period.between(doc['dataNascimento'].value.toLocalDate(),Instant.ofEpochMilli(System.currentTimeMillis()).atZone(doc['dataNascimento'].value.getZone()).toLocalDate()).getYears())",
" ^---- HERE"
],
"script" : "emit(Period.between(doc['dataNascimento'].value.toLocalDate(),Instant.ofEpochMilli(System.currentTimeMillis()).atZone(doc['dataNascimento'].value.getZone()).toLocalDate()).getYears())",
"lang" : "painless",
"position" : {
"offset" : 41,
"start" : 0,
"end" : 183
},
"caused_by" : {
"type" : "illegal_state_exception",
"reason" : "A document doesn't have a value for a field! Use doc[<field>].size()==0 to check if a document is missing a field!"
}
}
},
"status" : 400
}
And Elasticsearch return this Error Log:
{"type": "server", "timestamp": "2021-06-01T14:44:09,226Z", "level": "INFO", "component": "o.e.c.r.a.AllocationService", "cluster.name": "es-docker-cluster", "node.name": "es01", "message": "Cluster health status changed from [YELLOW] to [RED] (reason: [shards failed [[runtime_2_indexed_field][0]]]).", "cluster.uuid": "V323m4OOQ6unO0QSXX8dLg", "node.id": "HUIHyG0lTSGBLN7EiNdZAw" }
{"type": "server", "timestamp": "2021-06-01T14:44:26,991Z", "level": "INFO", "component": "o.e.c.r.a.AllocationService", "cluster.name": "es-docker-cluster", "node.name": "es01", "message": "Cluster health status changed from [RED] to [YELLOW] (reason: [shards started [[runtime_2_indexed_field][0]]]).", "cluster.uuid": "V323m4OOQ6unO0QSXX8dLg", "node.id": "HUIHyG0lTSGBLN7EiNdZAw" }
I tried to do this on Elastic Cloud too, and I happened this same error.