Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "aggregations" : {
- "level1" : {
- "terms" : {
- "field" : "country",
- "size" : 0,
- },
- "aggregations" : {
- "orderAggs" : {
- "terms" : {
- "field" : "orderId",
- "size" : 0,
- },
- "aggregations" : {
- "totalQty" : {
- "max" : {
- "field" : "targetQty"
- }
- },
- "timeFilterAggs" : {
- "filter" : {
- "range" : {
- "timeTaken" : {
- "from" : null,
- "to" : 5000,
- "include_lower" : true,
- "include_upper" : true
- }
- }
- },
- "aggregations" : {
- "processed" : {
- "max" : {
- "field" : "processedQty"
- }
- }
- }
- }
- }
- },
- "sumProcessed" : {
- "sum_bucket" : {
- "buckets_path" : [ "order>timeFilter>processed" ]
- }
- },
- "sumTargeted" : {
- "sum_bucket" : {
- "buckets_path" : [ "order>totalQty" ]
- }
- },
- "processedRatio" : {
- "bucket_script" : {
- "script" : {
- "inline" : "(target != 0 && target != null)? processed / target * 100:0"
- },
- "buckets_path" : {
- "processed" : "sumProcessed",
- "target" : "sumTargeted"
- }
- }
- }
- }
- }
- }
- "aggregations": {
- "level1": {
- "doc_count_error_upper_bound": 0,
- "sum_other_doc_count": 0,
- "buckets": [
- {
- "key": "IN",
- "doc_count": 4,
- "orderAggs": {
- "doc_count_error_upper_bound": 0,
- "sum_other_doc_count": 0,
- "buckets": [
- {
- "key": "ID_1",
- "doc_count": 2,
- "totalQty": {
- "value": 2
- },
- "timeFilterAggs": {
- "doc_count": 2,
- "processed": {
- "value": 2
- }
- }
- },
- {
- "key": "ID_2",
- "doc_count": 2,
- "totalQty": {
- "value": 2
- },
- "timeFilterAggs": {
- "doc_count": 2,
- "processed": {
- "value": 2
- }
- }
- }
- ]
- },
- "sumProcessed": {
- "value": 4
- },
- "sumTargeted": {
- "value": 4
- },
- "processedRatio": {
- "value": 100.0
- }
- }]
- }
- }
- "aggregations": {
- "level1": {
- "doc_count_error_upper_bound": 0,
- "sum_other_doc_count": 0,
- "buckets": [
- {
- "key": "IN",
- "doc_count": 77,
- "orderAggs": {
- //I don't need to include this as part of result, but I need this data for calculation
- },
- "sumProcessed": {
- "value": 4
- },
- "sumTargeted": {
- "value": 4
- },
- "processedRatio": {
- "value": 100.0
- }
- }]
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement