DSL - How to calculate a percentage value?

Hi guys,

i'm trying to caclulate the relationship between two values, but i can't get the desired value.
This is my (DSL) _search:

"size": 0,
	"query": {
		"bool": {
   			"filter": [
       			{"term": {"h.cat": "order"}}
	"aggs": {
    	"rejects": {
        	"filter": {
            	"term": {
                	"c.order.status": "RJ"

I would like to show a KPI as:
count(rejects) / count(order) * 100

  • so the incidence of rejects on all orders.

I try also with "Bucket Script Aggregation", but I was not able to achieve my goal.

Could you please help me?

Thanks in advance!

Hi @Ely_96 .

Could you provide more document information, are h.cat and c.order nested fields?

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