forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Daniel Widdis <[email protected]>
- Loading branch information
Showing
1 changed file
with
152 additions
and
0 deletions.
There are no files selected for viewing
152 changes: 152 additions & 0 deletions
152
...common/src/yamlRestTest/resources/rest-api-spec/test/search_pipeline/80_sort_response.yml
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,152 @@ | ||
--- | ||
teardown: | ||
- do: | ||
search_pipeline.delete: | ||
id: "my_pipeline" | ||
ignore: 404 | ||
|
||
--- | ||
"Test sort processor": | ||
- do: | ||
search_pipeline.put: | ||
id: "my_pipeline" | ||
body: > | ||
{ | ||
"description": "test pipeline", | ||
"response_processors": [ | ||
{ | ||
"sort": | ||
{ | ||
"field": "a", | ||
"target_field": "b" | ||
} | ||
} | ||
] | ||
} | ||
- match: { acknowledged: true } | ||
|
||
- do: | ||
search_pipeline.put: | ||
id: "my_pipeline_2" | ||
body: > | ||
{ | ||
"description": "test pipeline with ignore failure true", | ||
"response_processors": [ | ||
{ | ||
"sort": | ||
{ | ||
"field": "aa", | ||
"ignore_failure": true | ||
} | ||
} | ||
] | ||
} | ||
- match: { acknowledged: true } | ||
|
||
- do: | ||
search_pipeline.put: | ||
id: "my_pipeline_3" | ||
body: > | ||
{ | ||
"description": "test pipeline", | ||
"response_processors": [ | ||
{ | ||
"sort": | ||
{ | ||
"field": "a", | ||
"order": "desc", | ||
"target_field": "b" | ||
} | ||
} | ||
] | ||
} | ||
- match: { acknowledged: true } | ||
|
||
- do: | ||
indices.create: | ||
index: test | ||
|
||
- do: | ||
indices.put_mapping: | ||
index: test | ||
body: | ||
properties: | ||
a: | ||
type: integer | ||
store: true | ||
doc_values: true | ||
|
||
- do: | ||
index: | ||
index: test | ||
id: 1 | ||
body: { | ||
"a": [ 3, 1, 4 ] | ||
} | ||
|
||
- do: | ||
indices.refresh: | ||
index: test | ||
|
||
- do: | ||
search: | ||
body: { } | ||
- match: { hits.total.value: 1 } | ||
|
||
- do: | ||
search: | ||
index: test | ||
search_pipeline: "my_pipeline" | ||
body: { } | ||
- match: { hits.total.value: 1 } | ||
- match: { hits.hits.0._source: { "a": [3, 1, 4], "b": [1, 3, 4] } } | ||
|
||
# Should also work with no search body specified | ||
- do: | ||
search: | ||
index: test | ||
search_pipeline: "my_pipeline" | ||
- match: { hits.total.value: 1 } | ||
- match: { hits.hits.0._source: { "a": [3, 1, 4], "b": [1, 3, 4] } } | ||
|
||
# Pipeline with ignore_failure set to true | ||
# Should return while catching error | ||
- do: | ||
search: | ||
index: test | ||
search_pipeline: "my_pipeline_2" | ||
- match: { hits.total.value: 1 } | ||
- match: { hits.hits.0._source: { "a": [3, 1, 4] } } | ||
|
||
# Pipeline with desc sort order | ||
- do: | ||
search: | ||
index: test | ||
search_pipeline: "my_pipeline_3" | ||
body: { } | ||
- match: { hits.total.value: 1 } | ||
- match: { hits.hits.0._source: { "a": [3, 1, 4], "b": [4, 3, 1] } } | ||
|
||
# No source, using stored_fields | ||
- do: | ||
search: | ||
index: test | ||
search_pipeline: "my_pipeline" | ||
body: { | ||
"_source": false, | ||
"stored_fields": [ "a" ] | ||
} | ||
- match: { hits.hits.0.fields: { "a": [3, 1, 4], "b": [1, 3, 4] } } | ||
|
||
# No source, using docvalue_fields | ||
- do: | ||
search: | ||
index: test | ||
search_pipeline: "my_pipeline_3" | ||
body: { | ||
"_source": false, | ||
"docvalue_fields": [ "a" ] | ||
} | ||
# a is stored sorted for some unknown (to the test author) reason | ||
# which makes it really hard to write "expected" values on tests | ||
- match: { hits.hits.0.fields: { "a": [1, 3, 4], "b": [4, 3, 1] } } |