saradac
(Sarada Chelluboyena)
September 15, 2020, 11:26pm
1
Hi All,
I am using script in aggregation and need two things
min_doc_count
Use aggerartion in condition
All I am trying is to group by outlet and statationno and if count > 3 send alert.
Below is my script:
"aggs": {
"scripted": {
"terms": {
"script": {
"source": "doc['OutletId'].value + ' ' + doc['StationNo'].value"
},
"size": 3
}
}
}
saradac
(Sarada Chelluboyena)
September 15, 2020, 11:42pm
2
I fixed the aggregation condition. Still looking for min_doc_count
"aggs": {
"group_by_outlet": {
"terms": {
"script": {
"source": "doc['OutletId'].value + ' ' + doc['StationNo'].value"
}
}
}
}
saradac
(Sarada Chelluboyena)
September 16, 2020, 12:16am
3
All sorted.
"aggs": {
"group_by_outlet": {
"terms": {
"script": {
"source": "doc['OutletId'].value + ' ' + doc['StationNo'].value"
}
},
"aggs": {
"criticals": {
"bucket_selector": {
"buckets_path": {
"doc_count": "_count"
},
"script": "params.doc_count > 2"
}
}
}
}
}
"condition": {
"script": {
"source": "return (ctx.payload.aggregations.group_by_outlet.buckets.size() > 0 && ctx.payload.aggregations.group_by_outlet.buckets.0.doc_count >= params.threshold)",
"lang": "painless",
"params": {
"threshold": 3
}
}
}
1 Like
system
(system)
Closed
October 14, 2020, 12:16am
4
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.