[[query-dsl-script-query]]
=== Script query
++++
Script
++++
Filters documents based on a provided <>. The
`script` query is typically used in a <>.
WARNING: Using scripts can result in slower search speeds. See
<>.
[[script-query-ex-request]]
==== Example request
[source,console]
----
GET /_search
{
"query": {
"bool": {
"filter": {
"script": {
"script": {
"source": "doc['num1'].value > 1",
"lang": "painless"
}
}
}
}
}
}
----
[[script-top-level-params]]
==== Top-level parameters for `script`
`script`::
(Required, <>) Contains a script to run
as a query. This script must return a boolean value, `true` or `false`.
[[script-query-notes]]
==== Notes
[[script-query-custom-params]]
===== Custom Parameters
Like <>, scripts are cached for faster execution.
If you frequently change the arguments of a script, we recommend you store them
in the script's `params` parameter. For example:
[source,console]
----
GET /_search
{
"query": {
"bool": {
"filter": {
"script": {
"script": {
"source": "doc['num1'].value > params.param1",
"lang": "painless",
"params": {
"param1": 5
}
}
}
}
}
}
}
----
===== Allow expensive queries
Script queries will not be executed if <>
is set to false.