elasticsearch python queries - Group by field and then count elasticsearch python queries - Group by field and then count elasticsearch elasticsearch

elasticsearch python queries - Group by field and then count


Use below aggregation query to get total profit for each product.

{    "size": 0,     "aggs": {      "product_name": {          "terms": {              "field": "Product"          },          "aggs": {              "total_profit": {                  "sum": {                      "field": "Profit"                  }              }          }      }  }}

Note: Profit field must be any numeric type.