How to write a scripted field for nested fileds in index pattern

Hello guys, I want to write a scripted filed to get nested filed value.
I want to get the pressure value for each doc(record). Is it possible to do in Kibana?
My index is like this.

Thanks in advance!!

{
"_index": "process_data",
"_type": "_doc",
"_id": "UzFHVDM1MTAxMTk5QSAyMDAyMDAwOTUzN19TVDNBMjBfU1QzQTIwMTAwXzIwMjAtMDItMThUMTk6NDc6MzM=",
"_version": 1,
"_score": 1,
"_source": {
"eid": "",
"line": "Line 1",
"equipment": "Equipment 1",
"ladderver": "",
"registrydate": "2020-02-18T19:47:33",
"registryutcdate": "2020-02-18T10:47:33",
"setupid": "",
"workid": "2345743",
"datas": [
{
"datas_id": "001",
"name": "cycletime",
"value": "13.9"
}
,
{
"datas_id": "002",
"name": "machinetime",
"value": "10.7"
}
,
{
"datas_id": "003",
"name": "pressure",
"value": "12.56"
}
]
}
}

I could do it with the following scripted field.

for(item in params._source.datas)
{
    if(item.name=='pressure'){
      return item.value;
   }
}
return 0;

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