// This file is autogenerated, DO NOT EDIT
// aggregations/metrics/weighted-avg-aggregation.asciidoc:55

[source, python]
----
resp = client.search(
    index="exams",
    size=0,
    aggs={
        "weighted_grade": {
            "weighted_avg": {
                "value": {
                    "field": "grade"
                },
                "weight": {
                    "field": "weight"
                }
            }
        }
    },
)
print(resp)
----
