// This file is autogenerated, DO NOT EDIT
// aggregations/metrics/valuecount-aggregation.asciidoc:49

[source, python]
----
resp = client.search(
    index="sales",
    size=0,
    runtime_mappings={
        "tags": {
            "type": "keyword",
            "script": "\n        emit(doc['type'].value);\n        if (doc['promoted'].value) {\n          emit('hot');\n        }\n      "
        }
    },
    aggs={
        "tags_count": {
            "value_count": {
                "field": "tags"
            }
        }
    },
)
print(resp)
----
