I am trying to change the values of the fields while querying the data to Vega

So, I have data something like this

And I want the Data to be like :
Except for Closed and Submitted states it should change the value to In Progress

I know how this can be achieved through the scripted fields, but not sure where I should be using the scripted fields while pushing the data to Vega

Script Looks something like this :

if ((doc['state'].value != 'Closed') || (doc['state'].value != 'Submitted'))
{
return 'In Progress';
}

Please suggest anything what I should be doing in such case.

I got the issue solved by using the scripted fields in body, here is a sample

"data": [
    {
      "name": "source",
      "url": {
        "%context%": true,
        "%timefield%": "created",
        "index": "2.0.0-sampl-oper*",
        "body": {
          "size": 24,
          "_source": ["workitem", "state"],
          "script_fields": {
            "state": {
              "script": {
                "lang": "painless",
                "source": "if(doc['state'].value=='Closed')return 'Closed';if(doc['state'].value=='Submitted')return 'Not Started';else return 'In Progess';"
              }
            }
          }
        }
      },
      "format": {"property": "hits.hits"}
    }
]

But we cannot return the direct values of field itself and it should be a one line script.

1 Like

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