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

[source, js]
----
const response = await client.search({
  index: "products",
  runtime_mappings: {
    "genre.length": {
      type: "long",
      script: "emit(doc['genre'].value.length())",
    },
  },
  aggs: {
    genres_and_products: {
      multi_terms: {
        terms: [
          {
            field: "genre.length",
          },
          {
            field: "product",
          },
        ],
      },
    },
  },
});
console.log(response);
----
