2015-06-24 17:27:19 -04:00
|
|
|
[[java-query-dsl-script-query]]
|
|
|
|
==== Script Query
|
|
|
|
|
|
|
|
See {ref}/query-dsl-script-query.html[Script Query]
|
|
|
|
|
2017-05-02 13:00:56 -04:00
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
2015-06-24 17:27:19 -04:00
|
|
|
--------------------------------------------------
|
2017-05-02 13:00:56 -04:00
|
|
|
include-tagged::{query-dsl-test}[script_inline]
|
2015-06-24 17:27:19 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> inlined script
|
|
|
|
|
|
|
|
|
2016-06-27 09:55:16 -04:00
|
|
|
If you have stored on each data node a script named `myscript.painless` with:
|
2015-06-24 17:27:19 -04:00
|
|
|
|
2016-08-26 15:59:45 -04:00
|
|
|
[source,painless]
|
2015-06-24 17:27:19 -04:00
|
|
|
--------------------------------------------------
|
2016-06-27 09:55:16 -04:00
|
|
|
doc['num1'].value > params.param1
|
2015-06-24 17:27:19 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
You can use it then with:
|
|
|
|
|
2017-05-02 13:00:56 -04:00
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
2015-06-24 17:27:19 -04:00
|
|
|
--------------------------------------------------
|
2017-05-02 13:00:56 -04:00
|
|
|
include-tagged::{query-dsl-test}[script_file]
|
2015-06-24 17:27:19 -04:00
|
|
|
--------------------------------------------------
|
2016-12-12 08:41:42 -05:00
|
|
|
<1> Script type: either `ScriptType.FILE`, `ScriptType.INLINE` or `ScriptType.INDEXED`
|
|
|
|
<2> Scripting engine
|
|
|
|
<3> Script name
|
2017-05-02 13:00:56 -04:00
|
|
|
<4> Parameters as a `Map<String, Object>`
|