mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 18:35:25 +00:00
This change unifies the way scripts and templates are specified for all instances in the codebase. It builds on the Script class added previously and adds request building and parsing support as well as the ability to transfer script objects between nodes. It also adds a Template class which aims to provide the same functionality for template APIs Closes #11091
48 lines
1.0 KiB
Plaintext
48 lines
1.0 KiB
Plaintext
[[query-dsl-script-query]]
|
|
== Script Query
|
|
|
|
A query allowing to define
|
|
<<modules-scripting,scripts>> as filters. For
|
|
example:
|
|
|
|
[source,js]
|
|
----------------------------------------------
|
|
"filtered" : {
|
|
"query" : {
|
|
...
|
|
},
|
|
"filter" : {
|
|
"script" : {
|
|
"script" : "doc['num1'].value > 1"
|
|
}
|
|
}
|
|
}
|
|
----------------------------------------------
|
|
|
|
[float]
|
|
=== Custom Parameters
|
|
|
|
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:
|
|
|
|
[source,js]
|
|
----------------------------------------------
|
|
"filtered" : {
|
|
"query" : {
|
|
...
|
|
},
|
|
"filter" : {
|
|
"script" : {
|
|
"script" : {
|
|
"inline" : "doc['num1'].value > param1"
|
|
"params" : {
|
|
"param1" : 5
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
----------------------------------------------
|
|
|