You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and the response from opensearch:
{
"error": {
"root_cause": [
{
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: No aggregation found for path [../total_sales];"
}
],
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: No aggregation found for path [../total_sales];"
},
"status": 400
}
iam trying to access the total_sales inside each bucket to that i can perform percentage of sales in each bucket per total sales.but iam getting and error as shown above. is there any solutions for this?
Related component
No response
To Reproduce
Go to '...'
Click on '....'
Scroll down to '....'
See error
Expected behavior
iam expecting percentage of sales in each category.
Additional Details
OS: aws opensearch
Version 2.1
The text was updated successfully, but these errors were encountered:
Describe the bug
sample data:
POST sales_data/_bulk
{ "index": { "_id": 1 } }
{ "category": "electronics", "sales": 200 }
{ "index": { "_id": 2 } }
{ "category": "electronics", "sales": 100 }
{ "index": { "_id": 3 } }
{ "category": "furniture", "sales": 150 }
{ "index": { "_id": 4 } }
{ "category": "furniture", "sales": 200 }
{ "index": { "_id": 5 } }
{ "category": "clothing", "sales": 50 }
{ "index": { "_id": 6 } }
{ "category": "clothing", "sales": 100 }
{ "index": { "_id": 7 } }
{ "category": "electronics", "sales": 300 }
{ "index": { "_id": 8 } }
{ "category": "furniture", "sales": 250 }
{ "index": { "_id": 9 } }
{ "category": "clothing", "sales": 150 }
query:
GET sales_data/_search
{
"size": 0,
"aggs": {
"total_sales": {
"sum": { "field": "sales" }
},
"sales_per_category": {
"terms": {
"field": "category.keyword",
"size": 10
},
"aggs": {
"category_sales": {
"sum": { "field": "sales" }
},
"sales_percentage": {
"bucket_script": {
"buckets_path": {
"categorySales": "category_sales",
"totalSales": "../total_sales"
},
"script": "params.categorySales / params.totalSales*100"
}
}
}
}
}
}
and the response from opensearch:
{
"error": {
"root_cause": [
{
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: No aggregation found for path [../total_sales];"
}
],
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: No aggregation found for path [../total_sales];"
},
"status": 400
}
iam trying to access the total_sales inside each bucket to that i can perform percentage of sales in each bucket per total sales.but iam getting and error as shown above. is there any solutions for this?
Related component
No response
To Reproduce
Expected behavior
iam expecting percentage of sales in each category.
Additional Details
The text was updated successfully, but these errors were encountered: