I perform two separate request for my aggregations as:
-
For sum of payments of bill number = 3
{ "query": { "bool": { "must": [ {"match": {"num_ra_bill_no": 2 }} ] } }, "aggs": { "upToDatePayment": { "sum": { "script": "doc['num_upto_date_qty'].value * doc['num_rate'].value " } } } }
-
For sum of payments of bill number less than 3
{ "query": { "bool": { "must": [ {"range": {"num_ra_bill_no": {"lt": 2 } }} ] } }, "aggs": { "previousPayment": { "sum": { "script": "doc['num_upto_date_qty'].value * doc['num_rate'].value " } } } }
As You can see both the request perform the same operations only the change is the filter.
Is there a way such that I can perform 1 aggregation on different filter and 2nd aggregation on another filter??