I built a bar chart graph that aggregates orders per label bucket (e.g: USD/CAD). Then I display the sum of orders price per bucket for each of the orders inside it.
My chart visualization returns a wrong price which seems to be coming approximated
This is my graph query request debug
{
"size": 0,
"_source": {
"excludes": []
},
"aggs": {
"3": {
"terms": {
"field": "label.keyword",
"size": 2,
"order": {
"_term": "desc"
}
},
"aggs": {
"2": {
"terms": {
"field": "orders.id",
"size": 40,
"order": {
"1": "desc"
}
},
"aggs": {
"1": {
"sum": {
"field": "orders.price"
}
}
}
}
}
}
},
"stored_fields": [
"*"
],
"script_fields": {},
"docvalue_fields": [],
"query": {
"bool": {
"must": [
{
"match_all": {}
}
],
"filter": [],
"should": [],
"must_not": []
}
}
}
And this is the response, which confirms the the orders.price
value is being approximated
{
"took": 9,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 124,
"max_score": 0,
"hits": []
},
"aggregations": {
"3": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 122,
"buckets": [
{
"2": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"1": {
"value": 0.003690590019687079
},
"key": 213481,
"doc_count": 1
},
{
"1": {
"value": 0.003690590019687079
},
"key": 213482,
"doc_count": 1
},
{
"1": {
"value": 0.003690590019687079
},
"key": 213483,
"doc_count": 1
},
{
"1": {
"value": 0.003690590019687079
},
"key": 213484,
"doc_count": 1
},
...
And this is the photo that confirms that my data is there and should be retrieving the right price from the order.price
What is more strange is that when I flatten my data and stop using an array of nested orders, the same graph will work and display the correct value for each order.
However, I need to have this bar chart working with my source data above. My data is structured with nested orders array for each label. Am I doing anything wrong while building my graph?