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