Modifiy a runtime field

If have a runtime filed in my index

"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:

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

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?

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