Scripted Field on Date in Kibana?

Is there any way to create scripted field on Empty Date field? I want to find pending number of SMS when message Submitted but not Delivered. I am getting Submitted date but delivered Date Empty.

if (doc['SubmittedOn'].value != 'NULL')
{
    if (doc['DeliveredOn'].value == 'NULL')
    {
        return 'Pending'
    }
}

But it is not working. Any way to change data type from date to string. ELK stack version 7.14.1

This worked for me:

if (doc['SubmittedOn'].size() > 0)
{
    if (doc['DeliveredOn'].size() == 0)
    {
        return 'Pending'
    }
}

return 'Delivered'

thanks For reply dear, let me try this.

Through this error.
Script is invalid. View script preview for details

Access fields with doc['some_field'].value .

These are the docs that I've used to test it:

POST test/_doc 
{
  "SubmittedOn": "2015-01-01",
  "DeliveredOn": null
}

POST test/_doc 
{
  "SubmittedOn": "2015-01-01",
  "DeliveredOn": "2015-01-01"
}


Could you share the script you've used and the full error?

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