mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-05 20:48:22 +00:00
We've had `QueryDSLDocumentationTests` for a while but it had a very hopeful comment at the top about how we want to make sure that the example in the query-dsl docs match up with the test but we never had anything that made *sure* that they did. This changes that! Now the examples from the query-dsl docs are all built from the `QueryDSLDocumentationTests`. All except for the percolator example because that is hard to do as it stands now. To make this easier this change moves `QueryDSLDocumentationTests` from core and into the high level rest client. This is useful for two reasons: 1. We expect the high level rest client to be able to use the builders. 2. The code that builds that docs doesn't check out all of Elasticsearch. It only checks out certain directories. Since we're already including snippets from that directory we don't have to make any changes to that process. Closes #24320
30 lines
954 B
Plaintext
30 lines
954 B
Plaintext
[[java-query-dsl-script-query]]
|
|
==== Script Query
|
|
|
|
See {ref}/query-dsl-script-query.html[Script Query]
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{query-dsl-test}[script_inline]
|
|
--------------------------------------------------
|
|
<1> inlined script
|
|
|
|
|
|
If you have stored on each data node a script named `myscript.painless` with:
|
|
|
|
[source,painless]
|
|
--------------------------------------------------
|
|
doc['num1'].value > params.param1
|
|
--------------------------------------------------
|
|
|
|
You can use it then with:
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{query-dsl-test}[script_file]
|
|
--------------------------------------------------
|
|
<1> Script type: either `ScriptType.FILE`, `ScriptType.INLINE` or `ScriptType.INDEXED`
|
|
<2> Scripting engine
|
|
<3> Script name
|
|
<4> Parameters as a `Map<String, Object>`
|