-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Augment painless execute API (#3589)
(cherry picked from commit 374de63)
- Loading branch information
1 parent
f413af8
commit a010b49
Showing
12 changed files
with
268 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...lobal/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample1.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
summary: Test context | ||
# method_request: POST /_scripts/painless/_execute | ||
description: > | ||
Run `POST /_scripts/painless/_execute`. | ||
The `painless_test` context is the default context. | ||
It runs scripts without additional parameters. | ||
The only variable that is available is `params`, which can be used to access user defined values. | ||
The result of the script is always converted to a string. | ||
# type: request | ||
value: |- | ||
{ | ||
"script": { | ||
"source": "params.count / params.total", | ||
"params": { | ||
"count": 100.0, | ||
"total": 1000.0 | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...lobal/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample2.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
summary: Filter context | ||
# method_request: POST /_scripts/painless/_execute | ||
description: > | ||
Run `POST /_scripts/painless/_execute` with a `filter` context. | ||
It treats scripts as if they were run inside a script query. | ||
For testing purposes, a document must be provided so that it will be temporarily indexed in-memory and is accessible from the script. | ||
More precisely, the `_source`, stored fields, and doc values of such a document are available to the script being tested. | ||
# type: request | ||
value: |- | ||
{ | ||
"script": { | ||
"source": "doc['field'].value.length() <= params.max_length", | ||
"params": { | ||
"max_length": 4 | ||
} | ||
}, | ||
"context": "filter", | ||
"context_setup": { | ||
"index": "my-index-000001", | ||
"document": { | ||
"field": "four" | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...lobal/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample3.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
summary: Score context | ||
# method_request: POST /_scripts/painless/_execute | ||
description: > | ||
Run `POST /_scripts/painless/_execute` with a `score` context. | ||
It treats scripts as if they were run inside a `script_score` function in a `function_score` query. | ||
# type: request | ||
value: |- | ||
{ | ||
"script": { | ||
"source": "doc['rank'].value / params.max_rank", | ||
"params": { | ||
"max_rank": 5.0 | ||
} | ||
}, | ||
"context": "score", | ||
"context_setup": { | ||
"index": "my-index-000001", | ||
"document": { | ||
"rank": 4 | ||
} | ||
} | ||
} |
Oops, something went wrong.