ElasticSearch aggregation from a given array of values -
i need aggregate given array having ids in 1 query. explaination follows-
i have array having sku ids
array( [0] => 34, [1] => 67, [2] => 12 )
i have orders index in orders.sku_id present
"_index":"orders", "_type":"orders", "_id":"249622367", "_score":1, "_source":{ "order":{ "id":"249622367", "sku.id":34, "gross_value":"310", "quantity":"1" } }, "_index":"orders", "_type":"orders", "_id":"249622364", "_score":1, "_source":{ "order":{ "id":"249622364", "sku.id":34, "gross_value":"510", "quantity":"2" } }, "_index":"orders", "_type":"orders", "_id":"249622365", "_score":1, "_source":{ "order":{ "id":"249622365", "sku.id":67, "gross_value":"560", "quantity":"2" } }
i want aggregation on gross_value , quantity having sku_id(from sku_ids array) histogram , desired output follows-
"aggregations": { "skus": { "buckets": [ { "sku_id": 34, "gross_value": "820", "quantity": "3" }, { "sku_id": 67, "gross_value": "560", "quantity": "2" }, { "sku_id": 12, "gross_value": 0, "quantity": 0 } ] } }
i tried terms aggregation on sku_id , sum aggregation on gross_value & quantity, couldn't through.
any appreciated.
thanks in advance.
Comments
Post a Comment