Skip to content

Commit

Permalink
Fix: GET _mapping with index in query.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Jul 8, 2024
1 parent a359a5a commit 9ec6b34
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Fixed optional field in `/_nodes` ([#365](https://github.com/opensearch-project/opensearch-api-specification/pull/365))
- Fixed `/{index}/_open` can return a `task` ([#376](https://github.com/opensearch-project/opensearch-api-specification/pull/376))
- Fixed `_source` in `bulk` responses ([#375](https://github.com/opensearch-project/opensearch-api-specification/pull/375))
- Fixed `/_mapping` with `index` in query ([#385](https://github.com/opensearch-project/opensearch-api-specification/pull/385))

### Security

Expand Down
95 changes: 84 additions & 11 deletions spec/namespaces/indices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ paths:
- $ref: '#/components/parameters/indices.get_mapping::query.cluster_manager_timeout'
- $ref: '#/components/parameters/indices.get_mapping::query.expand_wildcards'
- $ref: '#/components/parameters/indices.get_mapping::query.ignore_unavailable'
- $ref: '#/components/parameters/indices.get_mapping::query.index'
- $ref: '#/components/parameters/indices.get_mapping::query.local'
- $ref: '#/components/parameters/indices.get_mapping::query.master_timeout'
responses:
Expand Down Expand Up @@ -1288,23 +1289,23 @@ paths:
$ref: '#/components/responses/indices.forcemerge@200'
/{index}/_mapping:
get:
operationId: indices.get_mapping.1
x-operation-group: indices.get_mapping
operationId: indices.get_index_mapping.0
x-operation-group: indices.get_index_mapping
x-version-added: '1.0'
description: Returns mappings for one or more indices.
externalDocs:
url: https://opensearch.org/docs/latest/field-types/index/#get-a-mapping
parameters:
- $ref: '#/components/parameters/indices.get_mapping::path.index'
- $ref: '#/components/parameters/indices.get_mapping::query.allow_no_indices'
- $ref: '#/components/parameters/indices.get_mapping::query.cluster_manager_timeout'
- $ref: '#/components/parameters/indices.get_mapping::query.expand_wildcards'
- $ref: '#/components/parameters/indices.get_mapping::query.ignore_unavailable'
- $ref: '#/components/parameters/indices.get_mapping::query.local'
- $ref: '#/components/parameters/indices.get_mapping::query.master_timeout'
- $ref: '#/components/parameters/indices.get_index_mapping::path.index'
- $ref: '#/components/parameters/indices.get_index_mapping::query.allow_no_indices'
- $ref: '#/components/parameters/indices.get_index_mapping::query.cluster_manager_timeout'
- $ref: '#/components/parameters/indices.get_index_mapping::query.expand_wildcards'
- $ref: '#/components/parameters/indices.get_index_mapping::query.ignore_unavailable'
- $ref: '#/components/parameters/indices.get_index_mapping::query.local'
- $ref: '#/components/parameters/indices.get_index_mapping::query.master_timeout'
responses:
'200':
$ref: '#/components/responses/indices.get_mapping@200'
$ref: '#/components/responses/indices.get_index_mapping@200'
post:
operationId: indices.put_mapping.0
x-operation-group: indices.put_mapping
Expand Down Expand Up @@ -2370,6 +2371,14 @@ components:
type: object
additionalProperties:
$ref: '../schemas/indices.get_mapping.yaml#/components/schemas/IndexMappingRecord'
indices.get_index_mapping@200:
description: ''
content:
application/json:
schema:
type: object
additionalProperties:
$ref: '../schemas/indices.get_mapping.yaml#/components/schemas/IndexMappingRecord'
indices.get_settings@200:
description: ''
content:
Expand Down Expand Up @@ -3769,7 +3778,7 @@ components:
style: form
x-version-deprecated: 2.0.0
x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead.
indices.get_mapping::path.index:
indices.get_index_mapping::path.index:
in: path
name: index
description: |-
Expand All @@ -3780,6 +3789,16 @@ components:
schema:
$ref: '../schemas/_common.yaml#/components/schemas/Indices'
style: simple
indices.get_mapping::query.index:
in: query
name: index
description: |-
Comma-separated list of data streams, indices, and aliases used to limit
the request. Supports wildcards (`*`). To target all data streams and
indices, omit this parameter or use `*` or `_all`.
schema:
type: string
style: form
indices.get_mapping::query.allow_no_indices:
in: query
name: allow_no_indices
Expand Down Expand Up @@ -3834,6 +3853,60 @@ components:
style: form
x-version-deprecated: 2.0.0
x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead.
indices.get_index_mapping::query.allow_no_indices:
in: query
name: allow_no_indices
description: |-
If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices.
schema:
type: boolean
style: form
indices.get_index_mapping::query.cluster_manager_timeout:
name: cluster_manager_timeout
in: query
description: Operation timeout for connection to cluster-manager node.
schema:
$ref: '../schemas/_common.yaml#/components/schemas/Duration'
x-version-added: 2.0.0
indices.get_index_mapping::query.expand_wildcards:
in: query
name: expand_wildcards
description: |-
Type of index that wildcard patterns can match.
If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.
Supports comma-separated values, such as `open,hidden`.
Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
schema:
$ref: '../schemas/_common.yaml#/components/schemas/ExpandWildcards'
style: form
indices.get_index_mapping::query.ignore_unavailable:
in: query
name: ignore_unavailable
description: If `false`, the request returns an error if it targets a missing or closed index.
schema:
type: boolean
style: form
indices.get_index_mapping::query.local:
in: query
name: local
description: If `true`, the request retrieves information from the local node only.
schema:
type: boolean
default: false
style: form
indices.get_index_mapping::query.master_timeout:
in: query
name: master_timeout
description: |-
Period to wait for a connection to the master node.
If no response is received before the timeout expires, the request fails and returns an error.
deprecated: true
schema:
$ref: '../schemas/_common.yaml#/components/schemas/Duration'
style: form
x-version-deprecated: 2.0.0
x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead.
indices.get_settings::path.index:
in: path
name: index
Expand Down
54 changes: 54 additions & 0 deletions tests/_core/mapping.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
$schema: ../../json_schemas/test_story.schema.yaml

description: Test mappings endpoints.
prologues:
- path: /{index}
method: PUT
parameters:
index: movies
request_body:
payload:
mappings:
properties:
director:
type: text
year:
type: integer
location:
type: ip
ignore_malformed: true
epilogues:
- path: /movies
method: DELETE
status: [200, 404]
chapters:
- synopsis: Get mappings for an index (index in query).
path: /_mapping
method: GET
parameters:
index: movies
response:
status: 200
payload:
movies:
mappings:
properties:
director:
type: text
year:
type: integer
- synopsis: Get mappings for an index (index in path).
path: /{index}/_mapping
method: GET
parameters:
index: movies
response:
status: 200
payload:
movies:
mappings:
properties:
director:
type: text
year:
type: integer

0 comments on commit 9ec6b34

Please sign in to comment.