# Modifiy a runtime field

**URL:** <https://discuss.elastic.co/t/modifiy-a-runtime-field/330430>\
**Category:** Elasticsearch\
**Tags:** painless, runtime-fields\
**Created:** [April 20, 2023, 5:30pm UTC](https://discuss.elastic.co/t/modifiy-a-runtime-field/330430 "2023-04-20T17:30:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![abkrim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abkrim/32/20217_2.png) [@abkrim](https://discuss.elastic.co/u/abkrim)\
**Post date:** [April 20, 2023, 5:30pm UTC](https://discuss.elastic.co/t/modifiy-a-runtime-field/330430/1 "2023-04-20T17:30:30Z")

</div>

If have a runtime filed in my index

```auto
"runtime": {
        "total_consumption": {
          "type": "double",
          "script": {
            "source": """
          double sum = 0;
          if (doc['pa1_w'].size() == 0) { sum = sum + 0 } else { sum = sum + doc['pa1_w'].value}
          if (doc['pa2_w'].size() == 0) { sum = sum + 0 } else { sum = sum + doc['pa2_w'].value}
          if (doc['pa3_w'].size() == 0) { sum = sum + 0 } else { sum = sum + doc['pa3_w'].value}
          emit(sum);
        """,
            "lang": "painless"
          }
        }
      },

```

I need to change this runtime and i made this in Kibana:

```auto
POST /analyzers-2022111701/_close

## Get 
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "indices": {
    "analyzers-2022111701": {
      "closed": true
    }
  }
}

PUT /analyzers-2022111701/_mapping
{
  "properties": {
    "total_consumption": {
      "type": "double",
      "script": {
        "source": """
          double sum = 0;
          if (doc['pa1_w'].size() > 0) { sum += Math.abs(doc['pa1_w'].value) }
	  if (doc['pa2_w'].size() > 0) { sum += Math.abs(doc['pa2_w'].value) }
          if (doc['pa3_w'].size() > 0) { sum += Math.abs(doc['pa3_w'].value) }
          emit(sum);
        """,
        "lang": "painless"
      }
    }
  }
}

## Get 
{
  "acknowledged": true
}

POST /analyzers-2022111701/_open

## Get
{
  "acknowledged": true,
  "shards_acknowledged": true
}

```

But if run

```auto
GET /work-analyzers/_mapping

{
  "analyzers-2022111701": {
    "mappings": {
      "runtime": {
        "total_consumption": {
          "type": "double",
          "script": {
            "source": """
          double sum = 0;
          if (doc['pa1_w'].size() == 0) { sum = sum + 0 } else { sum = sum + doc['pa1_w'].value}
          if (doc['pa2_w'].size() == 0) { sum = sum + 0 } else { sum = sum + doc['pa2_w'].value}
          if (doc['pa3_w'].size() == 0) { sum = sum + 0 } else { sum = sum + doc['pa3_w'].value}
          emit(sum);
        """,
            "lang": "painless"
          }
        }
      },
...
}

```

What is wrong?

Do I need to delete the runtime field and recreate it?

I forget any steep?

---

<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:** [May 18, 2023, 5:31pm UTC](https://discuss.elastic.co/t/modifiy-a-runtime-field/330430/2 "2023-05-18T17:31:28Z")

</div>

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