diff --git a/CHANGELOG.md b/CHANGELOG.md index 39e986483..1da33396a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/spec/namespaces/_core.yaml b/spec/namespaces/_core.yaml index 6b032fc2f..283c64e50 100644 --- a/spec/namespaces/_core.yaml +++ b/spec/namespaces/_core.yaml @@ -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' @@ -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' @@ -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: diff --git a/tests/default/_core/search_shards.yaml b/tests/default/_core/search_shards.yaml new file mode 100644 index 000000000..ac3d70b51 --- /dev/null +++ b/tests/default/_core/search_shards.yaml @@ -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" + response: + status: 200 \ No newline at end of file diff --git a/tests/default/indices/search_shards.yaml b/tests/default/indices/search_shards.yaml new file mode 100644 index 000000000..f6102a5bc --- /dev/null +++ b/tests/default/indices/search_shards.yaml @@ -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" + response: + status: 200 \ No newline at end of file