language by setting the
lang parameter to
Scripting is available in many APIs, but we will use an example with the
function_score for demonstration purposes:
Enabling inline scripting on an unprotected Elasticsearch cluster is dangerous. See File scripts for a safer option.
Enabling stored scripts on an unprotected Elasticsearch cluster is dangerous. See File scripts for a safer option.
We store the script under the id
The function score query retrieves the script with id
You can save your scripts to a file in the
config/scripts/ directory on
every node. The
First, save this file as
config/scripts/my_script.js on every node
in the cluster:
doc["num"].value * factor
then use the script as follows: