Skip to content

Commit

Permalink
Add tests for SplitResponseProcessor (#526)
Browse files Browse the repository at this point in the history
* Add tests for SplitResponseProcessor

Signed-off-by: Daniel Widdis <[email protected]>

* Remove CHANGELOG entry for test addition

Signed-off-by: Daniel Widdis <[email protected]>

* Update docker image to include these changes

Signed-off-by: Daniel Widdis <[email protected]>

* Input should be a string not a single element array of string

Signed-off-by: Daniel Widdis <[email protected]>

---------

Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed Aug 26, 2024
1 parent 5d2b36c commit 3a9caa7
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ jobs:
tests: snapshot
- version: 2.17.0
hub: opensearchstaging
ref: '@sha256:ed4274522a50228f41b50f1a7ea86e6b52fa6737072fc151b2624d22aff80d56'
ref: '@sha256:1273489ebbedcb470ea13563dae4c6dc6b2ed431e87e686ed931ae0733034b25'
- version: 3.0.0
hub: opensearchstaging
ref: '@sha256:9f4eba4fe7e75368d70f0a7f09d737bff4742d2139087fa637a689bb9fcd9788'
ref: '@sha256:06af2ba4037f8423dc1a4ed3cd29108a1912774e7c659e73f0fac09e1bb2b63d'

name: test-opensearch-spec (version=${{ matrix.entry.version }}, hub=${{ matrix.entry.hub || 'opensearchproject' }}, tests=${{ matrix.entry.tests || 'default' }})
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added API spec for security plugin ([#271](https://github.com/opensearch-project/opensearch-api-specification/pull/271))
- Added `/_plugins/_security/api/certificates/` ([#439](https://github.com/opensearch-project/opensearch-api-specification/pull/439))
- Added `/_plugins/_ml/models/{model_id}/_deploy`, `_undeploy` and `knn_vector` type in `passage_embedding` ([#504](https://github.com/opensearch-project/opensearch-api-specification/pull/504))
- Added `PersonalizeSearchRanking`, `RetrievalAugmentedGeneration`, `Rerank`, `Collapse`, `TruncateHits` and `SplitResponseProcessor` ([#505](https://github.com/opensearch-project/opensearch-api-specification/pull/505))
- Added `PersonalizeSearchRanking`, `RetrievalAugmentedGeneration`, `Rerank`, `Collapse`, `TruncateHits`, `SortResponseProcessor` and `SplitResponseProcessor` ([#505](https://github.com/opensearch-project/opensearch-api-specification/pull/505))
- Added `/_plugins/_security/api/certificates/` to API spec ([#439](https://github.com/opensearch-project/opensearch-api-specification/pull/439))
- Added support for annotating and testing the API spec against multiple OpenSearch distributions ([#483](https://github.com/opensearch-project/opensearch-api-specification/pull/483))
- Added `read_time`, `write_time`, `queue_size` and `io_time_in_millis` to `IoStatDevice` ([#483](https://github.com/opensearch-project/opensearch-api-specification/pull/483))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$schema: ../../../../../../json_schemas/test_story.schema.yaml

description: |-
Test the creation of a search pipeline with a response processor.
Test the creation of a search pipeline with a filter_query request processor.
version: '>= 2.8'
prologues:
- path: /_bulk
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
$schema: ../../../../../../json_schemas/test_story.schema.yaml

description: |-
Test the creation of a search pipeline with split and sort response processors.
version: '>= 2.17'
prologues:
- path: /numbers/_doc/1
method: POST
parameters:
refresh: true
request:
payload:
number_string: 'zero,one,two,three'
status: [201]
epilogues:
- path: /_search/pipeline/numbers_pipeline
method: DELETE
status: [200, 404]
- path: /numbers
method: DELETE
status: [200, 404]
chapters:
- synopsis: Create search pipeline.
path: /_search/pipeline/{id}
method: PUT
parameters:
id: numbers_pipeline
request:
payload:
response_processors:
- split:
field: number_string
separator: ','
target_field: number_strings
- sort:
field: number_strings
order: asc
target_field: sorted_number_strings
response:
status: 200
payload:
acknowledged: true
- synopsis: Query created pipeline.
path: /_search/pipeline/{id}
method: GET
parameters:
id: numbers_pipeline
response:
status: 200
- synopsis: Search.
warnings:
multiple-paths-detected: false
path: /{index}/_search
method: GET
parameters:
index: numbers
search_pipeline: numbers_pipeline
response:
status: 200
payload:
hits:
total:
value: 1
hits:
- _index: numbers
_source:
number_string: 'zero,one,two,three'
number_strings:
# eslint-disable yml/sort-sequence-values
- zero
- one
- two
- three
# eslint-enable yml/sort-sequence-values
sorted_number_strings:
- one
- three
- two
- zero

0 comments on commit 3a9caa7

Please sign in to comment.