New

The executive guide to generative AI

Read more
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.

Script Query

edit

A query allowing to define scripts as queries. They are typically used in a filter context, for example:

"bool" : {
    "must" : {
        ...
    },
    "filter" : {
        "script" : {
            "script" : "doc['num1'].value > 1"
        }
    }
}

Custom Parameters

edit

Scripts are compiled and cached for faster execution. If the same script can be used, just with different parameters provider, it is preferable to use the ability to pass parameters to the script itself, for example:

"bool" : {
    "must" : {
        ...
    },
    "filter" : {
        "script" : {
            "script" : {
                "inline" : "doc['num1'].value > param1"
                "params" : {
                    "param1" : 5
                }
            }
        }
    }
}

On this page

Was this helpful?
Feedback