Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the documentation of create or update alias API #7641

Merged
merged 14 commits into from
Jul 23, 2024
83 changes: 83 additions & 0 deletions _api-reference/index-apis/update-alias.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
layout: default
title: Create or update alias
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be in title case if it's the name of the API?

Naarcha-AWS marked this conversation as resolved.
Show resolved Hide resolved
parent: Index APIs
nav_order: 5
---

# Create or update alias
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Naarcha-AWS marked this conversation as resolved.
Show resolved Hide resolved
**Introduced 1.0**
{: .label .label-purple }

You can use this API to add a data stream or index to an alias, or update the settings for an existing alias.
gaobinlong marked this conversation as resolved.
Show resolved Hide resolved


## Example

```json
POST sample-index/_alias/sample-alias
```

```json
POST sample-index/_alias/sample-alias
{
"routing":"test"
}
```
{% include copy-curl.html %}

## Path and HTTP methods

```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

json?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for these. They are meant to be copy and pasted individually depending on what endpoint the user selects.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Naarcha-AWS Based on the API template, shouldn't this have highlighting, though? @kolchfa-aws Can you verify?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, even though the path and HTTP method are not part of JSON, we still have the json formatting tag on these for consistency.

POST /<target>/_alias/<alias-name>
PUT /<target>/_alias/<alias-name>
POST /_alias/<alias-name>
PUT /_alias/<alias-name>
POST /<target>/_aliases/<alias-name>
PUT /<target>/_aliases/<alias-name>
POST /_aliases/<alias-name>
PUT /_aliases/<alias-name>
POST /<target>/_aliases
PUT /<target>/_aliases
PUT /_alias
```

## Path parameters

| Parameter | Data type | Description |
:--- | :--- | :---
| target | String | Comma-delimited list of data streams, indexes. Wildcard expressions (`*`) are supported. To target all data streams and indexes in a cluster, use `_all` or `*`. Optional. |
gaobinlong marked this conversation as resolved.
Show resolved Hide resolved
| alias-name | String | The alias name to be created or updated. Optional. |
gaobinlong marked this conversation as resolved.
Show resolved Hide resolved

## Query parameters

All query parameters are optional.

Parameter | Data Type | Description

Check failure on line 56 in _api-reference/index-apis/update-alias.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [OpenSearch.TableHeadings] 'Data Type' is a table heading and should be in sentence case. Raw Output: {"message": "[OpenSearch.TableHeadings] 'Data Type' is a table heading and should be in sentence case.", "location": {"path": "_api-reference/index-apis/update-alias.md", "range": {"start": {"line": 56, "column": 13}}}, "severity": "ERROR"}
gaobinlong marked this conversation as resolved.
Show resolved Hide resolved
:--- | :--- | :---
cluster_manager_timeout | Time | The amount of time to wait for a response from the cluster manager node. Default is `30s`.
gaobinlong marked this conversation as resolved.
Show resolved Hide resolved
timeout | Time | The amount of time to wait for a response from the cluster. Default is `30s`.
gaobinlong marked this conversation as resolved.
Show resolved Hide resolved

## Request body

In the request body, you can specify the index name, the alias name, and the settings for the alias. All fields are optional.

Field | Data Type | Description

Check failure on line 65 in _api-reference/index-apis/update-alias.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [OpenSearch.TableHeadings] 'Data Type' is a table heading and should be in sentence case. Raw Output: {"message": "[OpenSearch.TableHeadings] 'Data Type' is a table heading and should be in sentence case.", "location": {"path": "_api-reference/index-apis/update-alias.md", "range": {"start": {"line": 65, "column": 9}}}, "severity": "ERROR"}
gaobinlong marked this conversation as resolved.
Show resolved Hide resolved
:--- | :--- | :--- | :---
index | String | Comma-delimited list of data streams orindexes you want to associate with the alias. If this field is set, it will override the index name specified in the URL path.

Check failure on line 67 in _api-reference/index-apis/update-alias.md

View workflow job for this annotation

GitHub Actions / style-job

[vale] reported by reviewdog 🐶 [OpenSearch.Spelling] Error: orindexes. If you are referencing a setting, variable, format, function, or repository, surround it with tic marks. Raw Output: {"message": "[OpenSearch.Spelling] Error: orindexes. If you are referencing a setting, variable, format, function, or repository, surround it with tic marks.", "location": {"path": "_api-reference/index-apis/update-alias.md", "range": {"start": {"line": 67, "column": 55}}}, "severity": "ERROR"}
gaobinlong marked this conversation as resolved.
Show resolved Hide resolved
alias | String | The name of the alias. If this field is set, it will override the alias name specified in the URL path.
gaobinlong marked this conversation as resolved.
Show resolved Hide resolved
is_write_index | Boolean | Specifies whether the index should be a write index. An alias can only have one write index at a time. If a write request is submitted to a alias that links to multiple indexes, OpenSearch executes the request only on the write index.
gaobinlong marked this conversation as resolved.
Show resolved Hide resolved
routing | String | Used to assign a custom value to a shard for specific operations.
gaobinlong marked this conversation as resolved.
Show resolved Hide resolved
index_routing | String | Assigns a custom value to a shard only for index operations.
gaobinlong marked this conversation as resolved.
Show resolved Hide resolved
search_routing | String | Assigns a custom value to a shard only for search operations.
gaobinlong marked this conversation as resolved.
Show resolved Hide resolved
filter | Object | A filter to use with the alias, so the alias points to a filtered part of the index.
gaobinlong marked this conversation as resolved.
Show resolved Hide resolved

## Response

```json
{
"acknowledged": true
}
```

For more alias API operations, see [Index aliases]({{site.url}}{{site.baseurl}}/opensearch/index-alias/).
Loading