// This file is autogenerated, DO NOT EDIT
// Use `node scripts/generate-docs-examples.mjs` to generate the docs examples

[source, js]
----
const response = await 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",
      },
    },
  },
});
console.log(response);
----
