// 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: "exams",
  size: 0,
  runtime_mappings: {
    "grade.corrected": {
      type: "double",
      script: {
        source: "emit(Math.min(100, doc['grade'].value * params.correction))",
        params: {
          correction: 1.2,
        },
      },
    },
  },
  aggs: {
    grades_stats: {
      extended_stats: {
        field: "grade.corrected",
      },
    },
  },
});
console.log(response);
----
