How to perform the aggregation with doc_count value

is there any way to perform the aggregation for the string filed,

I tried with bucket_script, but it required for the int or number value.
note: I need to perform the arithmetic operation based on the doc_count

Request:

GET logstash-*/_search
{
"size": 0,
"aggs": {
"2": {
"date_histogram": {
"field": "@timestamp",
"interval": "1d",
"time_zone": "Europe/London",
"min_doc_count": 0
},
"aggs": {
"3" : {
"filters" : {
"filters" : {
"confirmed": {
"query_string": {
"query": "("status=Booking Confirmed")",
"analyze_wildcard": true
}
}
}
}
}
,"4" : {
"filters" : {
"filters" : {
"cancelled": {
"query_string": {
"query": "("status=Booking Cancelled")",
"analyze_wildcard": true
}
}
}
}
}
,
"succesrate": {
"bucket_script": {
"buckets_path": {
"one": "3._count",
"two": "4._count"
},
"script": "params.one / params.two"
}
}
}
}

  }

}

response:
{
"error": {
"root_cause": ,
"type": "search_phase_execution_exception",
"reason": "",
"phase": "fetch",
"grouped": true,
"failed_shards": ,
"caused_by": {
"type": "aggregation_execution_exception",
"reason": "buckets_path must reference either a number value or a single value numeric metric aggregation, got: java.lang.Object"
}
},
"status": 503
}

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