forked from opensearch-project/opensearch-api-specification
-
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.
Update API specifications for k-NN 2.17 changes (opensearch-project#588)
* Update API specifications for k-NN 2.17 changes Signed-off-by: Ryan Bogan <rbogan@amazon.com> * Add changelog entry Signed-off-by: Ryan Bogan <rbogan@amazon.com> * Refactor k-NN tests, change naming to match theme, and update changelog message Signed-off-by: Ryan Bogan <rbogan@amazon.com> * Add spaceType parameter to train model API Signed-off-by: Ryan Bogan <rbogan@amazon.com> * Update sha references and remove version checks for asynchronous search Signed-off-by: Ryan Bogan <rbogan@amazon.com> * Add version checks back for asynchronous search Signed-off-by: Ryan Bogan <rbogan@amazon.com> * Update changelog style for entry Signed-off-by: Ryan Bogan <rbogan@amazon.com> --------- Signed-off-by: Ryan Bogan <rbogan@amazon.com>
- Loading branch information
Showing
8 changed files
with
183 additions
and
5 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
$schema: ../../../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test search endpoint with knn query. | ||
version: '>= 2.17' | ||
|
||
prologues: | ||
- method: PUT | ||
path: /movies | ||
request: | ||
payload: | ||
settings: | ||
index: | ||
knn: true | ||
mappings: | ||
properties: | ||
recommendation_vector: | ||
type: knn_vector | ||
dimension: 8 | ||
space_type: l2 | ||
data_type: float | ||
mode: on_disk | ||
compression_level: 16x | ||
status: [200] | ||
- method: POST | ||
path: /_bulk | ||
request: | ||
content_type: application/x-ndjson | ||
payload: | ||
- {index: {_index: movies, _id: '1'}} | ||
- {recommendation_vector: [1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5], duration: 12.2} | ||
- {index: {_index: movies, _id: '2'}} | ||
- {recommendation_vector: [2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5], duration: 7.1} | ||
- {index: {_index: movies, _id: '3'}} | ||
- {recommendation_vector: [3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5], duration: 12.9} | ||
- {index: {_index: movies, _id: '4'}} | ||
- {recommendation_vector: [4.5, 4.5, 4.5, 4.5, 4.5, 4.5, 4.5, 4.5], duration: 1.2} | ||
- {index: {_index: movies, _id: '5'}} | ||
- {recommendation_vector: [5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5], duration: 3.7} | ||
- {index: {_index: movies, _id: '6'}} | ||
- {recommendation_vector: [6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5], duration: 10.3} | ||
- {index: {_index: movies, _id: '7'}} | ||
- {recommendation_vector: [7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5], duration: 5.5} | ||
- {index: {_index: movies, _id: '8'}} | ||
- {recommendation_vector: [8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5], duration: 4.4} | ||
- {index: {_index: movies, _id: '9'}} | ||
- {recommendation_vector: [9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5], duration: 8.9} | ||
status: [200] | ||
epilogues: | ||
- path: /movies | ||
method: DELETE | ||
status: [200, 404] | ||
|
||
chapters: | ||
- synopsis: Test k-NN disk-based search. | ||
method: POST | ||
path: /{index}/_search | ||
parameters: | ||
index: movies | ||
request: | ||
payload: | ||
query: | ||
knn: | ||
recommendation_vector: | ||
vector: [1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5] | ||
k: 5 | ||
method_parameters: | ||
ef_search: 512 | ||
rescore: | ||
oversample_factor: 10 | ||
response: | ||
status: 200 |
2 changes: 1 addition & 1 deletion
2
tests/default/_core/search/knn.yaml → tests/default/_core/search/knn/search.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
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,73 @@ | ||
$schema: ../../../json_schemas/test_story.schema.yaml | ||
|
||
description: Test training k-NN model with disk-based parameters. | ||
version: '>= 2.17' | ||
|
||
prologues: | ||
- method: PUT | ||
path: /movies | ||
request: | ||
payload: | ||
settings: | ||
index: | ||
knn: true | ||
mappings: | ||
properties: | ||
recommendation_vector: | ||
type: knn_vector | ||
dimension: 8 | ||
status: [200] | ||
- method: POST | ||
path: /_bulk | ||
request: | ||
content_type: application/x-ndjson | ||
payload: | ||
- {index: {_index: movies, _id: '1'}} | ||
- {recommendation_vector: [1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5], duration: 12.2} | ||
- {index: {_index: movies, _id: '2'}} | ||
- {recommendation_vector: [2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5], duration: 7.1} | ||
- {index: {_index: movies, _id: '3'}} | ||
- {recommendation_vector: [3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5], duration: 12.9} | ||
- {index: {_index: movies, _id: '4'}} | ||
- {recommendation_vector: [4.5, 4.5, 4.5, 4.5, 4.5, 4.5, 4.5, 4.5], duration: 1.2} | ||
- {index: {_index: movies, _id: '5'}} | ||
- {recommendation_vector: [5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5, 5.5], duration: 3.7} | ||
- {index: {_index: movies, _id: '6'}} | ||
- {recommendation_vector: [6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5], duration: 10.3} | ||
- {index: {_index: movies, _id: '7'}} | ||
- {recommendation_vector: [7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5], duration: 5.5} | ||
- {index: {_index: movies, _id: '8'}} | ||
- {recommendation_vector: [8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8.5], duration: 4.4} | ||
- {index: {_index: movies, _id: '9'}} | ||
- {recommendation_vector: [9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5], duration: 8.9} | ||
status: [200] | ||
epilogues: | ||
- path: /movies | ||
method: DELETE | ||
status: [200, 404] | ||
- path: /_plugins/_knn/models/{model_id} | ||
parameters: | ||
model_id: ${train_model.test_model_id} | ||
method: DELETE | ||
status: [200, 404] | ||
|
||
chapters: | ||
- synopsis: Test training a model with disk-based parameters. | ||
id: train_model | ||
method: POST | ||
path: /_plugins/_knn/models/_train | ||
request: | ||
payload: | ||
training_index: movies | ||
training_field: recommendation_vector | ||
dimension: 8 | ||
max_training_vector_count: 1200 | ||
search_size: 100 | ||
description: Test model | ||
mode: on_disk | ||
compression_level: 32x | ||
spaceType: l2 | ||
response: | ||
status: 200 | ||
output: | ||
test_model_id: payload.model_id |