Merge pull request #505 from alicejw-aws/os-bugs

to merge content and delete duplicate file - fix for issue 485
This commit is contained in:
Alice Williams 2022-04-13 10:49:00 -07:00 committed by GitHub
commit 7f7adf929b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 94 deletions

View File

@ -1,21 +1,24 @@
--- ---
layout: default layout: default
title: Put mapping title: Create or update mappings
parent: Index APIs parent: Index APIs
grand_parent: REST API reference grand_parent: REST API reference
nav_order: 200 nav_order: 220
--- ---
# Put mapping # Create or update mappings
Introduced 1.0 Introduced 1.0
{: .label .label-purple } {: .label .label-purple }
The put mapping API operation lets you add new mappings and fields to an index. If you want to create or add mappings and fields to an index, you can use the put mapping API operation. For an existing mapping, this operation updates the mapping.
You can't use this operation to update mappings that already map to existing data in the index. You must first create a new index with your desired mappings, and then use the [reindex API operation]({{site.url}}{{site.baseurl}}/opensearch/reindex-data) to map all the documents from your old index to the new index. If you don't want any downtime while you re-index your indexes, you can use [aliases]({{site.url}}{{site.baseurl}}/opensearch/index-alias).
## Example ## Example
```json ```json
PUT /sample-index/_mapping PUT /sample-index/_mapping
{ {
"properties": { "properties": {
"age": { "age": {
@ -36,23 +39,29 @@ PUT /<target-index>/_mapping
PUT /_mapping PUT /_mapping
``` ```
You can also use the put mapping operation to update multiple indexes with one request.
```
PUT /<target-index1>,<target-index2>/_mapping
```
## URL parameters ## URL parameters
All put mapping parameters are optional. All put mapping parameters are optional.
Parameter | Data Type | Description Parameter | Data Type | Description
:--- | :--- | :--- :--- | :--- | :---
&lt;target-index&gt; | Data Type | The index to add the mapping to. If you do not specify this parameter, OpenSearch adds the mapping to all indices within the cluster. &lt;target-index&gt; | N/A | Specifies an index with which to associate the mapping. If you do not specify this parameter, OpenSearch adds the mapping to all indexes within the cluster.
allow_no_indices | Boolean | Whether to ignore wildcards that dont match any indices. Default is `true`. allow_no_indices | Boolean | Whether to ignore wildcards that dont match any indexes. Default is `true`.
expand_wildcards | String | Expands wildcard expressions to different indices. Combine multiple values with commas. Available values are `all` (match all indices), `open` (match open indices), `closed` (match closed indices), `hidden` (match hidden indices), and `none` (do not accept wildcard expressions), which must be used with `open`, `closed`, or both. Default is `open`. expand_wildcards | String | Expands wildcard expressions to different indexes. Combine multiple values with commas. Available values are `all` (match all indexes), `open` (match open indexes), `closed` (match closed indexes), `hidden` (match hidden indexes), and `none` (do not accept wildcard expressions), which must be used with `open`, `closed`, or both. Default is `open`.
ignore_unavailable | Boolean | If true, OpenSearch does not include missing or closed indices in the response. ignore_unavailable | Boolean | If true, OpenSearch does not include missing or closed indexes in the response.
master_timeout | Time | How long to wait for a connection to the master node. Default is `30s`. master_timeout | Time | How long to wait for a connection to the master node. Default is `30s`.
timeout | Time | How long to wait for a response from the cluster. Default is `30s`. timeout | Time | How long to wait for the response to return. Default is `30s`.
write_index_only | Boolean | Whether OpenSearch should add the mapping only to write indexes. If false, OpenSearch can add the mapping to all indexes with the same alias. See [alias]({{site.url}}{{site.baseurl}}/opensearch/rest-api/alias/#request-body) for more information. Default is false. write_index_only | Boolean | Whether OpenSearch should apply mapping updates only to the write index.
## Request body ## Request body
The request body must contain the `properties` object, which has all of the mappings that you want to add. The request body must contain `properties`, which has all of the mappings that you want to create or update.
```json ```json
{ {

View File

@ -1,83 +0,0 @@
---
layout: default
title: Update mapping
parent: Index APIs
grand_parent: REST API reference
nav_order: 220
---
# Update mapping
Introduced 1.0
{: .label .label-purple }
If you want to update an index's mappings to add or update field types after index creation, you can do so with the update mapping API operation.
Note that you cannot use this operation to update mappings that already map to existing data in the index. You must first create a new index with your desired mappings, and then use the [reindex API operation]({{site.url}}{{site.baseurl}}/opensearch/reindex-data) to map all the documents from your old index to the new index. If you don't want any downtime while reindexing your indices, you can use [aliases]({{site.url}}{{site.baseurl}}/opensearch/index-alias).
## Example
```json
PUT /sample-index/_mapping
{
"properties": {
"age": {
"type": "integer"
},
"occupation":{
"type": "text"
}
}
}
```
## Path and HTTP methods
```
PUT /<target-index>/_mapping
```
You can also use the update mapping operation to update multiple indices with one request.
```
PUT /<target-index1>,<target-index2>/_mapping
```
## URL parameters
All update mapping parameters are optional.
Parameter | Data Type | Description
:--- | :--- | :---
allow_no_indices | Boolean | Whether to ignore wildcards that dont match any indices. Default is `true`.
expand_wildcards | String | Expands wildcard expressions to different indices. Combine multiple values with commas. Available values are `all` (match all indices), `open` (match open indices), `closed` (match closed indices), `hidden` (match hidden indices), and `none` (do not accept wildcard expressions), which must be used with `open`, `closed`, or both. Default is `open`.
ignore_unavailable | Boolean | If true, OpenSearch does not include missing or closed indices in the response.
master_timeout | Time | How long to wait for a connection to the master node. Default is `30s`.
timeout | Time | How long to wait for the response to return. Default is `30s`.
write_index_only | Boolean | Whether OpenSearch should apply mapping updates only to the write index.
## Request body
The request body must contain `properties`, which has all of the mappings that you want to update.
```json
{
"properties":{
"color":{
"type": "text"
},
"year":{
"type": "integer"
}
}
}
```
## Response
```json
{
"acknowledged": true
}
```