Skip to content

Commit

Permalink
Merge branch 'main' into ingest-pipeline-processor
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <tsfarr@amazon.com>
  • Loading branch information
Xtansia authored Nov 24, 2024
2 parents e63d8ac + 7e08a43 commit 16a4805
Show file tree
Hide file tree
Showing 10 changed files with 279 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added `PhoneAnalyzer` from `analysis-phonenumber` plugin ([#609](https://github.com/opensearch-project/opensearch-api-specification/pull/609))
- Added `/_list/indices` & `/_list/shards` api specs ([#613](https://github.com/opensearch-project/opensearch-api-specification/pull/613))
- Added `GET` and `HEAD /{index}/_source/{id}` returning `404` ([#673](https://github.com/opensearch-project/opensearch-api-specification/pull/673))
- Added `rename_alias_pattern` and `rename_alias_replacment` to `/_snapshot/{repository}/{snapshot}/_restore` body parameters ([#615](https://github.com/opensearch-project/opensearch-api-specification/pull/615))
- Added `s` to `/_ingest/processor/grok` ([#689](https://github.com/opensearch-project/opensearch-api-specification/pull/689))

### Removed
Expand Down
2 changes: 1 addition & 1 deletion spec/namespaces/replication.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,4 @@ components:
content:
application/json:
schema:
$ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase'
$ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase'
47 changes: 42 additions & 5 deletions spec/namespaces/snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ components:
type: object
properties:
ignore_unavailable:
description: If `true`, the request ignores data streams and indexes in `indices` that are missing or closed. If `false`, the request returns an error for any data stream or index that is missing or closed.
description: If `true`, the request ignores data streams and indexes in `indexes` that are missing or closed. If `false`, the request returns an error for any data stream or index that is missing or closed.
type: boolean
include_global_state:
description: If `true`, the current cluster state is included in the snapshot. The cluster state includes persistent cluster settings, composable index templates, legacy index templates, ingest pipelines, and ILM policies. It also includes data stored in system indexes, such as Watches and task records (configurable with `feature_states`).
Expand Down Expand Up @@ -335,30 +335,67 @@ components:
schema:
type: object
properties:
feature_states:
type: array
items:
type: string
ignore_index_settings:
description: A comma-delimited list of index settings that you don't want to restore from a snapshot.
type: array
items:
type: string
ignore_unavailable:
type: boolean
description: How to handle data streams or indexes that are missing or closed. If `false`, the request returns an error for any data stream or index that is missing or closed. If `true`, the request ignores data streams and indexes in indexes that are missing or closed. Defaults to `false`.
include_aliases:
type: boolean
description: How to handle index aliases from the original snapshot. If `true`, index aliases from the original snapshot are restored. If `false`, aliases along with associated indexes are not restored. Defaults to `true`.
include_global_state:
type: boolean
description: Whether to restore the current cluster state. If `false`, the cluster state is not restored. If true, the current cluster state is restored. Defaults to `false`.
index_settings:
description: A comma-delimited list of settings to add or change in all restored indexes. Use this parameter to override index settings during snapshot restoration. For data streams, these index settings are applied to the restored backing indexes.
$ref: '../schemas/indices._common.yaml#/components/schemas/IndexSettings'
indices:
description: A comma-delimited list of data streams and indexes to restore from the snapshot. Multi-index syntax is supported. By default, a restore operation includes all data streams and indexes in the snapshot. If this argument is provided, the restore operation only includes the data streams and indexes that you specify.
$ref: '../schemas/_common.yaml#/components/schemas/Indices'
partial:
type: boolean
description: |-
How the restore operation will behave if indexes in the snapshot do not have all primary shards available.
If `false`, the entire restore operation fails if any indexes in the snapshot do not have all primary shards available.
If `true`, allows the restoration of a partial snapshot of indexes with unavailable shards. Only shards that were successfully included in the snapshot are restored. All missing shards are recreated as empty. By default, the entire restore operation fails if one or more indexes included in the snapshot do not have all primary shards available. To change this behavior, set `partial` to `true`.
Defaults to `false`.
rename_pattern:
type: string
description: |-
The pattern to apply to the restored data streams and indexes. Data streams and indexes matching the rename pattern will be renamed according to the `rename_replacement` setting.
The rename pattern is applied as defined by the regular expression that supports referencing the original text.
The request fails if two or more data streams or indexes are renamed into the same name.
If you rename a restored data stream, its backing indexes are also renamed. For example, if you rename the logs data stream to `recovered-logs`, the backing index `.ds-logs-1` is renamed to `.ds-recovered-logs-1`.
If you rename a restored stream, ensure an index template matches the new stream name. If there are no matching index template names, the stream cannot roll over and new backing indexes are not created.
rename_replacement:
type: string
description: The rename replacement string.
rename_alias_pattern:
x-version-added: '2.18'
type: string
description: |-
The pattern to apply to the restored aliases. Aliases matching the rename pattern will be renamed according to the `rename_alias_replacement` setting.
The rename pattern is applied as defined by the regular expression that supports referencing the original text.
If two or more aliases are renamed into the same name, these aliases will be merged into one.
rename_alias_replacement:
x-version-added: '2.18'
type: string
description: The rename replacement string for aliases.
source_remote_store_repository:
x-version-added: '2.10'
type: string
description: The name of the remote store repository of the source index being restored. If not provided, the Snapshot Restore API will use the repository that was registered when the snapshot was created.
storage_type:
x-version-added: '2.7'
type: string
description: |-
Where will be the authoritative store of the restored indexes' data.
A value of `local` indicates that all snapshot metadata and index data will be downloaded to local storage.
A value of `remote_snapshot` indicates that snapshot metadata will be downloaded to the cluster, but the remote repository will remain the authoritative store of the index data. Data will be downloaded and cached as necessary to service queries. At least one node in the cluster must be configured with the search role in order to restore a snapshot using the type `remote_snapshot`.
Defaults to `local`.
description: Details of what to restore
responses:
snapshot.cleanup_repository@200:
Expand Down
29 changes: 29 additions & 0 deletions tests/default/indices/explain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,32 @@ chapters:
title: Drive
response:
status: 200
- synopsis: Explain the score using the Lucene query string syntax in the request body.
path: /{index}/_explain/{id}
method: POST
parameters:
index: movies
id: movie2
request:
payload:
query:
query_string:
default_field: title
query: Drive
analyzer: english
response:
status: 200
- synopsis: Explain the score using the Lucene query string syntax in parameters.
path: /{index}/_explain/{id}
method: GET
parameters:
index: movies
id: movie2
q: Drive
df: title
lenient: true
analyzer: english
default_operator: and
analyze_wildcard: true
response:
status: 200
61 changes: 61 additions & 0 deletions tests/default/indices/mapping/field.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
$schema: ../../../../json_schemas/test_story.schema.yaml

description: Test specific field mappings endpoints.
prologues:
- path: /{index}
method: PUT
parameters:
index: movies
request:
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: Add new fields to index mapping.
path: /{index}/_mapping
method: POST
parameters:
index: movies
request:
payload:
properties:
genre:
type: text
rating:
type: float
response:
status: 200
payload:
acknowledged: true
- synopsis: Get specific field mappings for an index.
path: /{index}/_mapping/field/{fields}
method: GET
parameters:
index: movies
fields: director,year
response:
status: 200
payload:
movies:
mappings:
year:
full_name: year
mapping:
year:
type: integer
director:
full_name: director
mapping:
director:
type: text
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$schema: ../../../json_schemas/test_story.schema.yaml
$schema: ../../../../json_schemas/test_story.schema.yaml

description: Test mappings endpoints.
prologues:
Expand Down Expand Up @@ -145,4 +145,4 @@ chapters:
response:
status: 200
payload:
acknowledged: true
acknowledged: true
36 changes: 36 additions & 0 deletions tests/default/indices/msearch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test endpoints relevant to the lifecycle of an index, including multi-get and multi-search operations.
prologues:
- path: /_bulk
method: POST
parameters:
refresh: true
request:
content_type: application/x-ndjson
payload:
- {create: {_index: books, _id: book1}}
- {author: Harper Lee, title: To Kill a Mockingbird, year: 60}
- {create: {_index: books, _id: book2}}
- {director: Bennett Miller, title: The Cruise, year: 1998}
- {create: {_index: books, _id: book3}}
- {director: Nicolas Winding Refn, title: Drive, year: 1960}
epilogues:
- path: /books
method: DELETE
status: [200, 404]
chapters:
- synopsis: Perform a `_msearch` request to execute multiple search queries in a single call.
path: /{index}/_msearch
method: POST
parameters:
index: books
request:
content_type: application/x-ndjson
payload:
- {index: books}
- {query: {match: {title: To Kill a Mockingbird}}}
- {index: books}
- {query: {match: {title: The Cruise}}}
response:
status: 200
2 changes: 1 addition & 1 deletion tests/default/indices/refresh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ chapters:
status: 200
payload:
_shards:
failed: 0
failed: 0
49 changes: 49 additions & 0 deletions tests/default/indices/validate/query.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
$schema: ../../../../json_schemas/test_story.schema.yaml

description: Test validating queries for a specific index 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: Bennett Miller, title: The Cruise, year: 1998}
- {create: {_index: movies, _id: movie2}}
- {director: Nicolas Winding Refn, title: Drive, year: 1960}
chapters:
- synopsis: Validate a match query (GET).
path: /{index}/_validate/query
method: GET
parameters:
index: movies
request:
payload:
query:
match:
year: 1998
response:
status: 200
payload:
valid: true

- synopsis: Validate a match query (POST).
path: /{index}/_validate/query
method: POST
parameters:
index: movies
request:
payload:
query:
match:
title: Drive
response:
status: 200
payload:
valid: true
58 changes: 57 additions & 1 deletion tests/snapshot/snapshot/restore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ epilogues:
- path: /books
method: DELETE
status: [200, 404]
- path: /stories
method: DELETE
status: [200, 404]
- path: /stories_restored
method: DELETE
status: [200, 404]
prologues:
- path: /_snapshot/{repository}
method: PUT
Expand All @@ -33,6 +39,16 @@ prologues:
method: PUT
- path: /books
method: PUT
- path: /stories
method: PUT
- path: /_aliases
method: POST
request:
payload:
actions:
- add:
index: stories
alias: stories_alias
- path: /_snapshot/{repository}/{snapshot}
method: PUT
parameters:
Expand All @@ -44,6 +60,7 @@ prologues:
indices:
- books
- movies
- stories
ignore_unavailable: true
include_global_state: false
partial: true
Expand All @@ -53,6 +70,9 @@ prologues:
- path: /books
method: DELETE
status: [200, 404]
- path: /stories
method: DELETE
status: [200, 404]
chapters:
- synopsis: Restore snapshot with `wait_for_completion` true.
path: /_snapshot/{repository}/{snapshot}/_restore
Expand Down Expand Up @@ -98,4 +118,40 @@ chapters:
- stage: DONE
type: SNAPSHOT
retry:
count: 3
count: 3
- synopsis: Restore snapshot with rename_pattern and rename_replacement.
path: /_snapshot/{repository}/{snapshot}/_restore
method: POST
parameters:
repository: my-fs-repository
snapshot: my-test-snapshot
wait_for_completion: true
request:
payload:
indices: stories
rename_pattern: '^(.*)$'
rename_replacement: $1_restored
response:
status: 200
payload:
snapshot:
snapshot: my-test-snapshot
- synopsis: Restore snapshot with rename_alias_pattern and rename_alias_replacement.
version: '>= 2.18'
path: /_snapshot/{repository}/{snapshot}/_restore
method: POST
parameters:
repository: my-fs-repository
snapshot: my-test-snapshot
wait_for_completion: true
request:
payload:
indices: stories
include_aliases: true
rename_alias_pattern: '^(.*)$'
rename_alias_replacement: $1_restored
response:
status: 200
payload:
snapshot:
snapshot: my-test-snapshot

0 comments on commit 16a4805

Please sign in to comment.