Skip to content

Commit

Permalink
adding search_shards test
Browse files Browse the repository at this point in the history
Signed-off-by: Tokesh <[email protected]>
  • Loading branch information
Tokesh committed Dec 7, 2024
1 parent 866897a commit 8057935
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- 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 `_type` to `rank_eval` API specs ([#704](https://github.com/opensearch-project/opensearch-api-specification/pull/704))
- Added request body to `_search_shards` 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
44 changes: 44 additions & 0 deletions spec/namespaces/_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,8 @@ paths:
- $ref: '#/components/parameters/search_shards::query.local'
- $ref: '#/components/parameters/search_shards::query.preference'
- $ref: '#/components/parameters/search_shards::query.routing'
requestBody:
$ref: '#/components/requestBodies/search_shards'
responses:
'200':
$ref: '#/components/responses/search_shards@200'
Expand Down Expand Up @@ -2021,6 +2023,8 @@ paths:
- $ref: '#/components/parameters/search_shards::query.local'
- $ref: '#/components/parameters/search_shards::query.preference'
- $ref: '#/components/parameters/search_shards::query.routing'
requestBody:
$ref: '#/components/requestBodies/search_shards'
responses:
'200':
$ref: '#/components/responses/search_shards@200'
Expand Down Expand Up @@ -2690,6 +2694,46 @@ components:
type: string
description: The search definition template and its parameters.
required: true
search_shards:
content:
application/json:
schema:
type: object
properties:
query:
description: Defines the search query to filter shards. Supports any query that is valid for the `_search` endpoint.
type: object
additionalProperties:
type: object
indices_boost:
description: Allows increasing the relevance of specific indices in the search.
type: object
additionalProperties:
type: number
allow_partial_search_results:
description: Indicates whether partial search results are allowed if some shards are unavailable.
type: boolean
_source:
description: Specifies which fields to include in the `_source` response or excludes specific fields.
oneOf:
- type: boolean
- type: array
items:
type: string
from:
description: The starting offset (default 0) for paginated results.
type: integer
size:
description: The maximum number of results to return (default 10).
type: integer
sort:
description: A list of fields and directions for sorting the results.
type: array
items:
type: object
additionalProperties:
type: string
description: Defines the parameters that can be used in the `search_shards` endpoint request. See documentation for supported query syntax.
termvectors:
content:
application/json:
Expand Down
37 changes: 37 additions & 0 deletions tests/default/_core/search_shards.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test _search_shards APIs.
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}
epilogues:
- path: /movies
method: DELETE
status: [200, 404]

chapters:
- synopsis: Verify the distribution of shards for the index.
path: /_search_shards
method: GET
response:
status: 200

- synopsis: Check routing behavior based on search criteria.
path: /_search_shards
method: POST
request:
payload:
query:
match:
title: "To Kill a Mockingbird"

Check failure on line 35 in tests/default/_core/search_shards.yaml

View workflow job for this annotation

GitHub Actions / lint

Must use plain style scalar

Check failure on line 35 in tests/default/_core/search_shards.yaml

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote
response:
status: 200
41 changes: 41 additions & 0 deletions tests/default/indices/search_shards.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test _search_shards APIs.
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}
epilogues:
- path: /movies
method: DELETE
status: [200, 404]

chapters:
- synopsis: Verify the distribution of shards for the index.
path: /{index}/_search_shards
parameters:
index: movies
method: GET
response:
status: 200

- synopsis: Check routing behavior based on search criteria.
path: /{index}/_search_shards
parameters:
index: movies
method: POST
request:
payload:
query:
match:
title: "To Kill a Mockingbird"

Check failure on line 39 in tests/default/indices/search_shards.yaml

View workflow job for this annotation

GitHub Actions / lint

Must use plain style scalar

Check failure on line 39 in tests/default/indices/search_shards.yaml

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote
response:
status: 200

0 comments on commit 8057935

Please sign in to comment.