From 951a2e01f1d183ca76d4176d068b6e86475a91cb Mon Sep 17 00:00:00 2001 From: keithhc2 Date: Thu, 15 Jul 2021 16:38:05 -0700 Subject: [PATCH 1/3] Added update mapping to API reference and fixed some metadata --- _opensearch/rest-api/alias.md | 3 +- _opensearch/rest-api/create-index.md | 3 +- _opensearch/rest-api/update-mapping.md | 78 ++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 _opensearch/rest-api/update-mapping.md diff --git a/_opensearch/rest-api/alias.md b/_opensearch/rest-api/alias.md index f703d63f..04730109 100644 --- a/_opensearch/rest-api/alias.md +++ b/_opensearch/rest-api/alias.md @@ -2,8 +2,7 @@ layout: default title: Alias parent: REST API reference -grand_parent: OpenSearch -nav_order: 8 +nav_order: 5 --- # Alias diff --git a/_opensearch/rest-api/create-index.md b/_opensearch/rest-api/create-index.md index 348cb839..9ad89acb 100644 --- a/_opensearch/rest-api/create-index.md +++ b/_opensearch/rest-api/create-index.md @@ -2,8 +2,7 @@ layout: default title: Create index parent: REST API reference -grand_parent: OpenSearch -nav_order: 7 +nav_order: 3 --- # Create index diff --git a/_opensearch/rest-api/update-mapping.md b/_opensearch/rest-api/update-mapping.md new file mode 100644 index 00000000..f6230d1c --- /dev/null +++ b/_opensearch/rest-api/update-mapping.md @@ -0,0 +1,78 @@ +--- +layout: default +title: Update mapping +parent: REST API reference +nav_order: 6 +--- + +# Update mapping + +If you want to update an index's type mappings after its creation, you can do so with the update mapping API operation. + +## Example + +```json +PUT /sample-index/_mapping + +{ + "properties": { + "age": { + "type": "integer" + }, + "occupation":{ + "type": "text" + } + } +} +``` + + +## Path and HTTP methods + +``` +PUT //_mapping +``` + +You can also use the update mapping operation to update multiple indices with one request. + +``` +PUT /,/_mapping +``` + +## URL parameters + +All update mapping parameters are optional. + +Parameter | Data Type | Description +:--- | :--- | :--- +allow_no_indices | Boolean | If false, the request returns an error if any wildcard expresion or index alias targets any closed or missing indices. Defaults to false. +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 | If true, the specified mappings are applied 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 +} +``` From 9574bd2c3062a35df2abbc3a858b9745b57f0340 Mon Sep 17 00:00:00 2001 From: keithhc2 Date: Thu, 15 Jul 2021 16:42:16 -0700 Subject: [PATCH 2/3] Minor language tweak --- _opensearch/rest-api/update-mapping.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_opensearch/rest-api/update-mapping.md b/_opensearch/rest-api/update-mapping.md index f6230d1c..fa2965a3 100644 --- a/_opensearch/rest-api/update-mapping.md +++ b/_opensearch/rest-api/update-mapping.md @@ -7,7 +7,7 @@ nav_order: 6 # Update mapping -If you want to update an index's type mappings after its creation, you can do so with the update mapping API operation. +If you want to update an index's mappings after creating the index, you can do so with the update mapping API operation. ## Example From 2b31c5392c6f16993d0a8844d2bb5bb1d9910c7c Mon Sep 17 00:00:00 2001 From: keithhc2 Date: Wed, 21 Jul 2021 11:31:27 -0700 Subject: [PATCH 3/3] Added some additional context --- _opensearch/rest-api/update-mapping.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/_opensearch/rest-api/update-mapping.md b/_opensearch/rest-api/update-mapping.md index fa2965a3..0d0d451c 100644 --- a/_opensearch/rest-api/update-mapping.md +++ b/_opensearch/rest-api/update-mapping.md @@ -7,7 +7,9 @@ nav_order: 6 # Update mapping -If you want to update an index's mappings after creating the index, you can do so with the update mapping API operation. +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