Scripted field failed to create

I have created the scripted field as the following. I hope to perform a divide calculation for the sum of field1 and field2 with field3. But the below scripted fields can't be calculated. What's wrong with the below script?

(doc['field1'].value + doc['field2'].value) / doc['field3'].value

What are the types for field1, field2, and field3? What error message is getting returned?

The best way to debug scripted fields is in the Dev tools application. Below is an example search command that uses scripted fields like your example

GET logstash-0/_search
{
  "query": {
    "match_all": {}
  },
  "script_fields" : {
    "myScriptedField" : {
      "script" : {
        "lang": "painless",
        "source": "(doc['bytes'].value + doc['bytes'].value) / doc['bytes'].value"
      }
    }
  }
}

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