Scripted field is not showing value of destination.domain field

Hi,

I am using ElasticSearch and Kibana 7x version, I am trying to concatenate two fields values.

Before I write actual concatenation painless script, I tried accessing field values from scripted field.

when I run the query doc['destination.domain'].value it is not giving any values instead it is showing []
But the actual values of destination.domain field is something like test.mydomain.com.

What could be the issue causing this error?

hello,
Can you show us the entire script and a sample document?

Somehow it is showing the null value [] in preview results. But when I create the field and access the value from discover section, the value is coming properly. The script I wrote like

if (doc['destination.domain'].size()!=0 && doc['file.val'].size()!=0){ 
    return doc['destination.domain'].value + '' + doc['file.val''].value
}

If it shows [ ] in the preview results is due to there being no documents in the last 10 that match your script, for example those with destination.domain being empty.