// 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: "exams",
  size: 0,
  runtime_mappings: {
    "grade.weighted": {
      type: "double",
      script:
        "\n        emit(doc['grade'].value * doc['weight'].value)\n      ",
    },
  },
  aggs: {
    grades_stats: {
      stats: {
        field: "grade.weighted",
      },
    },
  },
});
console.log(response);
----
