Thanks Roy! I have seen View API but could not find how to use it with vega specification. I will be seeing your example links more closely.
Let me provide you my example in detail. I have a log file which I read using logstash and put into ElasticSearch. Some sample data stored into ElasticSearch are as below -
note: @timestamp in the below data is the event timestamp when the data was read by logstash.
{
"audit_message":"Operation_ABC",
"step_id":4,
"@timestamp":"2017-12-01T03:15:22.000Z",
"exec_time":2.457235
}
{
"audit_message":"Step_DEF",
"step_id":5,
"@timestamp":"2017-12-01T03:15:27.084Z",
"exec_time":0.020198,
"parent_step_id":4
}
{
"audit_message":"Operation_GHI",
"step_id":6,
"@timestamp":"2017-12-01T03:15:32.175Z",
"exec_time":0.015176,
"parent_step_id":5
}
{
"audit_message":"Function_JKL",
"step_id":5,
"@timestamp":"2017-12-01T03:17:34.182Z",
"exec_time":4.46E-4,
"parent_step_id":4
}
{
"audit_message":"Function_MNO",
"step_id":6,
"@timestamp":"2017-12-01T03:17:39.254Z",
"exec_time":1.56E-4,
"parent_step_id":5
}
{
"audit_message":"Operation_PQR",
"step_id":6,
"@timestamp":"2017-12-01T03:17:44.345Z",
"exec_time":0.003522,
"parent_step_id":5
}
I want to have a visualization as below

As you can understand from the above example that the parent-child set is determined with two conditions.
1) parent's step_id = child's step_id -1
and 2) parent's timestamp is the immediate previous timestamp of the child.
While using stratify I was looking for to generate the parentKey from the transformation itself. I used lookup transformation but, that was only meeting the condition #1.
Here is the entire transformation.
"transform": [
{
"type": "lookup",
"from": "records", <----- records data is the same record set as above.
"key": "_source.step_id", <---- ignore _source here. _source was added to my search result when queried from ElasticSearch
"fields": ["_source.parent_step_id"],
"values": ["_source.@timestamp"],
"as": ["parent_timestamp"],
"default": null
},
{
"type": "stratify",
"key": "_source.@timestamp",
"parentKey": "parent_timestamp"
},
{
"type": "tree",
"method": {"signal": "layout"},
"size": [
{"signal": "height"},
{"signal": "width - 100"}
],
"as": ["y", "x", "depth", "children"]
}
]
I want to search the data with the above two conditions either by API or by transformation.