// 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({
  runtime_mappings: {
    "price.discounted": {
      type: "double",
      script:
        "\n        double price = doc['price'].value;\n        if (doc['product'].value == 'mad max') {\n          price *= 0.8;\n        }\n        emit(price);\n      ",
    },
  },
  size: 0,
  aggs: {
    my_buckets: {
      composite: {
        sources: [
          {
            price: {
              histogram: {
                interval: 5,
                field: "price.discounted",
              },
            },
          },
        ],
      },
    },
  },
});
console.log(response);
----
