Skip to content

Commit

Permalink
adding rank_eval indices API tests (opensearch-project#704)
Browse files Browse the repository at this point in the history
* adding rank_eval indices api specs

Signed-off-by: Tokesh <tokesh789@gmail.com>

* lint for ci and verbose check early versions

Signed-off-by: Tokesh <tokesh789@gmail.com>

* adding _type parameter to rank-eval specs

Signed-off-by: Tokesh <tokesh789@gmail.com>

* fixing reference and adding changelog

Signed-off-by: Tokesh <tokesh789@gmail.com>

* adding rank_eval global

Signed-off-by: Tokesh <tokesh789@gmail.com>

* removing verbose flag from ci

Signed-off-by: Tokesh <tokesh789@gmail.com>

* missing one link in changelog

Signed-off-by: Tokesh <tokesh789@gmail.com>

---------

Signed-off-by: Tokesh <tokesh789@gmail.com>
Signed-off-by: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com>
  • Loading branch information
Tokesh authored Dec 3, 2024
1 parent 3981d33 commit 0ee21a8
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added `s` to `/_ingest/processor/grok` ([#689](https://github.com/opensearch-project/opensearch-api-specification/pull/689))
- Added schema for security API error responses ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646))
- Added `aggregations` to `/nodes/_usage/{metric}` requests and responses ([#615](https://github.com/opensearch-project/opensearch-api-specification/pull/615))
- Added missing `status` to `/_search/template` response([#702](https://github.com/opensearch-project/opensearch-api-specification/pull/702))
- Added missing `status` to `/_search/template` response ([#702](https://github.com/opensearch-project/opensearch-api-specification/pull/702))
- Added `_type` to `rank_eval` API specs ([#704](https://github.com/opensearch-project/opensearch-api-specification/pull/704))

### Removed
- Removed unsupported `_common.mapping:SourceField`'s `mode` field and associated `_common.mapping:SourceFieldMode` enum ([#652](https://github.com/opensearch-project/opensearch-api-specification/pull/652))
Expand Down Expand Up @@ -50,6 +51,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Fixed `/_scripts/painless/_execute` request and response schema ([#699](https://github.com/opensearch-project/opensearch-api-specification/pull/699))
- Fixed `fields` in `Hit` allowing primitive arrays ([#699](https://github.com/opensearch-project/opensearch-api-specification/pull/699))
- Added missing `repository` query parameter to `/_cat/snapshots` ([#700](https://github.com/opensearch-project/opensearch-api-specification/pull/700))
- Fixed `hits` in `rank_eval` allowing numbers ([#704](https://github.com/opensearch-project/opensearch-api-specification/pull/704))

### Changed
- Changed `tasks._common:TaskInfo` and `tasks._common:TaskGroup` to be composed of a `tasks._common:TaskInfoBase` ([#683](https://github.com/opensearch-project/opensearch-api-specification/pull/683))
Expand Down
4 changes: 3 additions & 1 deletion spec/schemas/_core.rank_eval.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ components:
additionalProperties:
type: object
additionalProperties:
type: object
type: number
required:
- hits
- metric_details
Expand Down Expand Up @@ -168,6 +168,8 @@ components:
$ref: '_common.yaml#/components/schemas/IndexName'
_score:
type: number
_type:
$ref: '_common.yaml#/components/schemas/Type'
required:
- _id
- _index
Expand Down
62 changes: 62 additions & 0 deletions tests/default/_core/rank_eval.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test rank evaluation API using both GET and POST methods.
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
prologues:
- path: /_bulk
method: POST
parameters:
refresh: true
request:
content_type: application/x-ndjson
payload:
- {create: {_index: movies, _id: movie1}}
- {director: Quentin Tarantino, title: Pulp Fiction, year: 1994}
- {create: {_index: movies, _id: movie2}}
- {director: Christopher Nolan, title: Inception, year: 2010}

chapters:
- synopsis: Perform rank evaluation using GET.
path: /_rank_eval
method: GET
request:
payload:
metric:
precision:
k: 10
requests:
- id: query_1
request:
query:
match:
title: Pulp Fiction
ratings:
- _id: movie1
rating: 1
_index: movies
response:
status: 200

- synopsis: Perform rank evaluation using POST.
path: /_rank_eval
method: POST
request:
payload:
metric:
mean_reciprocal_rank:
k: 10
requests:
- id: query_2
request:
query:
match:
director: Christopher Nolan
ratings:
- _id: movie2
_index: movies
rating: 1
response:
status: 200
66 changes: 66 additions & 0 deletions tests/default/indices/rank_eval.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test rank evaluation API using both GET and POST methods.
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
prologues:
- path: /_bulk
method: POST
parameters:
refresh: true
request:
content_type: application/x-ndjson
payload:
- {create: {_index: movies, _id: movie1}}
- {director: Quentin Tarantino, title: Pulp Fiction, year: 1994}
- {create: {_index: movies, _id: movie2}}
- {director: Christopher Nolan, title: Inception, year: 2010}

chapters:
- synopsis: Perform rank evaluation using GET.
path: /{index}/_rank_eval
method: GET
parameters:
index: movies
request:
payload:
metric:
precision:
k: 10
requests:
- id: query_1
request:
query:
match:
title: Pulp Fiction
ratings:
- _id: movie1
rating: 1
_index: movies
response:
status: 200

- synopsis: Perform rank evaluation using POST.
path: /{index}/_rank_eval
method: POST
parameters:
index: [movies]
request:
payload:
metric:
mean_reciprocal_rank:
k: 10
requests:
- id: query_2
request:
query:
match:
director: Christopher Nolan
ratings:
- _id: movie2
_index: movies
rating: 1
response:
status: 200

0 comments on commit 0ee21a8

Please sign in to comment.