Script

Scripted queries

/ Script_score, / Script, / _Script, / Scripting

Scripted queries #

Scripts in the search request: script_score to compute the score, a script predicate in a boolean filter, and a _script sort key. All run on Pizza’s sandboxed script engine (see the script language reference) — Rhai, not Painless, but the doc['x'].value, _score, params.<name> spellings run unmodified.

script_score — score by script #

Wrap a query; the script’s value replaces the score. The script sees _score (the wrapped query’s BM25 score), doc (the hit’s _source in doc-values shape) and params:

...

Pipeline scripts

/ Script, / Aggregation

Pipeline scripts #

Three pipeline aggregations evaluate a user-supplied script per bucket: bucket_script (compute a new metric per bucket), bucket_selector (keep/drop predicate), and moving_fn (window statistic). moving_avg is a moving_fn with a fixed averaging script. The same engine powers scripted_metric (scripts per document instead of per bucket) and the scripted value sources on the single-value metric aggs (sum, avg, min, max, value_count, cardinality), the per-hit script_fields of a search request (fetch phase), and the scripted queries — script_score, script filters, the _script sort.

...