# Elasticsearch 7.13 | Error deleting field mapping script, cluster return red state

**URL:** <https://discuss.elastic.co/t/elasticsearch-7-13-error-deleting-field-mapping-script-cluster-return-red-state/274655>\
**Category:** Elasticsearch\
**Created:** [June 1, 2021, 2:48pm UTC](https://discuss.elastic.co/t/elasticsearch-7-13-error-deleting-field-mapping-script-cluster-return-red-state/274655 "2021-06-01T14:48:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joao/32/83447_2.png) [@joao](https://discuss.elastic.co/u/joao)\
**Post date:** [June 1, 2021, 2:48pm UTC](https://discuss.elastic.co/t/elasticsearch-7-13-error-deleting-field-mapping-script-cluster-return-red-state/274655/1 "2021-06-01T14:48:33Z")

</div>

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:

```auto
    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:

```auto
    POST runtime_2_indexed_field/_doc/1
    {
      "dataNascimento": "1991-06-01"
    }

```

But when I try to delete this document, it's return this error:

```auto
    {
      "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:

```auto
    {"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.

 ![ClusterRed](https://us1.discourse-cdn.com/elastic/original/3X/2/a/2a8baab26d25f1eeb6dc7e5ebbcc725060f6d2b0.jpeg)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 29, 2021, 2:49pm UTC](https://discuss.elastic.co/t/elasticsearch-7-13-error-deleting-field-mapping-script-cluster-return-red-state/274655/2 "2021-06-29T14:49:07Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
