Hi guys, I am using scripted field to find the time difference and using this in Data table visualization, but it's giving timeout error.
Scripted field is working and showing in discover tab but not working during aggregation:
Please help I am stuck!!!
Query being fired by Data Table:
{
"size": 0,
"_source": {
"excludes": []
},
"aggs": {
"2": {
"terms": {
"field": "host.keyword",
"size": 5,
"order": {
"1": "desc"
}
},
"aggs": {
"1": {
"min": {
"script": {
"inline": "new Date().getTime() - doc['@timestamp'].date.getMillis()",
"lang": "painless"
}
}
}
}
}
},
"stored_fields": [
"*"
],
"script_fields": {
"time-diff": {
"script": {
"inline": "new Date().getTime() - doc['@timestamp'].date.getMillis()",
"lang": "painless"
}
}
},
"docvalue_fields": [
"@timestamp"
],
"query": {
"bool": {
"must": [
{
"match_all": {}
},
{
"range": {
"@timestamp": {
"gte": 1513936575384,
"lte": 1513940175384,
"format": "epoch_millis"
}
}
}
],
"filter": [],
"should": [],
"must_not": []
}
}
}