-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed scripts endpoints. #699
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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 |
---|---|---|
|
@@ -19,4 +19,3 @@ components: | |
required: | ||
- document | ||
- index | ||
- query |
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
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,13 @@ | ||
$schema: ../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test _recovery endpoint. | ||
chapters: | ||
- synopsis: Get information about any completed or ongoing shard recoveries for all indexes. | ||
path: /_recovery | ||
warnings: | ||
multiple-paths-detected: false | ||
method: GET | ||
parameters: | ||
human: true | ||
response: | ||
status: 200 |
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,11 @@ | ||
$schema: ../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test the _script_context endpoint to retrieve available script contexts. | ||
|
||
chapters: | ||
- synopsis: Retrieve available script languages. | ||
version: '>= 2.1' | ||
path: /_script_language | ||
method: GET | ||
response: | ||
status: 200 |
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,128 @@ | ||
$schema: ../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test the _scripts endpoint. | ||
|
||
prologues: | ||
- path: /_bulk | ||
method: POST | ||
parameters: | ||
refresh: true | ||
request: | ||
content_type: application/x-ndjson | ||
payload: | ||
- {create: {_index: books}} | ||
- {author: Harper Lee, title: To Kill a Mockingbird, year: 1960, ratings: [1, 2, 3]} | ||
- {create: {_index: books}} | ||
- {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991, ratings: [3, 4, 5]} | ||
epilogues: | ||
- path: /books | ||
method: DELETE | ||
status: [200, 404] | ||
- path: /_scripts/add_ratings | ||
method: DELETE | ||
status: [200, 404] | ||
- path: /_scripts/average_ratings | ||
method: DELETE | ||
status: [200, 404] | ||
chapters: | ||
- synopsis: Create a painless script that sums the ratings (PUT). | ||
path: /_scripts/{id} | ||
method: PUT | ||
parameters: | ||
id: add_ratings | ||
request: | ||
payload: | ||
script: | ||
lang: painless | ||
source: |- | ||
int total = 0; | ||
for (int i = 0; i < doc['ratings'].length; ++i) { | ||
total += doc['ratings'][i]; | ||
} | ||
return total; | ||
response: | ||
status: 200 | ||
- synopsis: Get ratings sum (PUT). | ||
path: /{index}/_search | ||
method: POST | ||
warnings: | ||
multiple-paths-detected: false | ||
parameters: | ||
index: books | ||
request: | ||
payload: | ||
query: | ||
match_all: {} | ||
script_fields: | ||
ratings_sum: | ||
script: | ||
id: add_ratings | ||
response: | ||
status: 200 | ||
payload: | ||
hits: | ||
hits: | ||
- fields: | ||
ratings_sum: | ||
- 6 | ||
- fields: | ||
ratings_sum: | ||
- 12 | ||
- synopsis: Create a painless script that calculates a ratings average (POST). | ||
path: /_scripts/{id} | ||
method: POST | ||
parameters: | ||
id: average_ratings | ||
request: | ||
payload: | ||
script: | ||
lang: painless | ||
source: |- | ||
if (doc['ratings'].length > 0) { | ||
int total = 0; | ||
for (int i = 0; i < doc['ratings'].length; ++i) { | ||
total += doc['ratings'][i]; | ||
} | ||
return total / doc['ratings'].length; | ||
} else { | ||
return 0; | ||
} | ||
response: | ||
status: 200 | ||
- synopsis: Score results by ratings average (POST). | ||
path: /{index}/_search | ||
method: POST | ||
warnings: | ||
multiple-paths-detected: false | ||
parameters: | ||
index: books | ||
request: | ||
payload: | ||
query: | ||
script_score: | ||
query: | ||
match_all: {} | ||
script: | ||
id: average_ratings | ||
response: | ||
status: 200 | ||
payload: | ||
hits: | ||
hits: | ||
- _score: 4 | ||
- _score: 2 | ||
- synopsis: Get a script. | ||
path: /_scripts/{id} | ||
method: GET | ||
parameters: | ||
id: add_ratings | ||
response: | ||
status: 200 | ||
payload: | ||
_id: add_ratings | ||
found: true | ||
- synopsis: Delete script. | ||
path: /_scripts/{id} | ||
method: DELETE | ||
parameters: | ||
id: add_ratings |
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,41 @@ | ||
$schema: ../../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test the _scripts contexts endpoint. | ||
|
||
prologues: | ||
- path: /_scripts/add_ratings | ||
method: DELETE | ||
status: [200, 404] | ||
chapters: | ||
- synopsis: Create a painless script that sums the ratings. | ||
path: /_scripts/{id}/{context} | ||
method: POST | ||
parameters: | ||
id: add_ratings | ||
context: field | ||
request: | ||
payload: | ||
script: | ||
lang: painless | ||
source: |- | ||
int total = 0; | ||
for (int i = 0; i < doc['ratings'].length; ++i) { | ||
total += doc['ratings'][i]; | ||
} | ||
return total; | ||
response: | ||
status: 200 | ||
- synopsis: Update a painless script that sums the ratings. | ||
path: /_scripts/{id}/{context} | ||
method: PUT | ||
parameters: | ||
id: add_ratings | ||
context: field | ||
request: | ||
payload: | ||
script: | ||
lang: painless | ||
source: |- | ||
return 0; | ||
response: | ||
status: 200 |
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,69 @@ | ||
$schema: ../../../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test the _scripts execute endpoint. | ||
|
||
prologues: | ||
- path: /movies | ||
method: PUT | ||
request: | ||
payload: | ||
mappings: | ||
properties: | ||
year: | ||
type: integer | ||
epilogues: | ||
- path: /movies | ||
method: DELETE | ||
status: [200, 404] | ||
chapters: | ||
- synopsis: Execute a painless script returning a string. | ||
path: /_scripts/painless/_execute | ||
method: GET | ||
request: | ||
payload: | ||
script: | ||
source: |- | ||
(params.x + params.y)/2 | ||
params: | ||
x: 80 | ||
y: 100 | ||
response: | ||
status: 200 | ||
payload: | ||
result: '90' | ||
- synopsis: Execute a painless script returning `false`. | ||
path: /_scripts/painless/_execute | ||
method: POST | ||
request: | ||
payload: | ||
context: filter | ||
context_setup: | ||
index: movies | ||
document: | ||
year: 1976 | ||
script: | ||
source: |- | ||
doc['year'].value > params.year | ||
params: | ||
year: 2000 | ||
response: | ||
status: 200 | ||
payload: | ||
result: false | ||
- synopsis: Execute a painless script returning a number. | ||
path: /_scripts/painless/_execute | ||
method: POST | ||
request: | ||
payload: | ||
context: score | ||
context_setup: | ||
index: movies | ||
document: | ||
year: 1976 | ||
script: | ||
source: |- | ||
doc['year'].value | ||
response: | ||
status: 200 | ||
payload: | ||
result: 1976 |
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,32 @@ | ||
$schema: ../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test _recovery endpoint. | ||
prologues: | ||
- path: /movies | ||
method: PUT | ||
status: [200] | ||
epilogues: | ||
- path: /movies | ||
method: DELETE | ||
status: [200, 404] | ||
chapters: | ||
- synopsis: Get information about any completed or ongoing shard recoveries for an index. | ||
path: /{index}/_recovery | ||
warnings: | ||
multiple-paths-detected: false | ||
method: GET | ||
parameters: | ||
index: movies | ||
response: | ||
status: 200 | ||
payload: | ||
movies: | ||
shards: | ||
- stage: DONE | ||
index: | ||
size: | ||
total_in_bytes: 0 | ||
translog: | ||
total: 0 | ||
verify_index: | ||
total_time_in_millis: 0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can also do
type: [number, string, boolean]
Non blocker