[source, ruby]
----
response = client.search(
  index: 'exams',
  size: 0,
  body: {
    runtime_mappings: {
      'grade.corrected' => {
        type: 'double',
        script: {
          source: "emit(Math.min(100, doc['grade'].value * params.correction))",
          params: {
            correction: 1.2
          }
        }
      }
    },
    aggregations: {
      avg_corrected_grade: {
        avg: {
          field: 'grade.corrected'
        }
      }
    }
  }
)
puts response
----
