From ed6f8ddd3b5f3e2bb2f572811fab5ce6eca2a40f Mon Sep 17 00:00:00 2001 From: alicejw Date: Thu, 26 May 2022 14:23:25 -0700 Subject: [PATCH 1/4] for doc bug https://github.com/opensearch-project/documentation-website/issues/565 Signed-off-by: alicejw --- _opensearch/rest-api/index-apis/put-mapping.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/_opensearch/rest-api/index-apis/put-mapping.md b/_opensearch/rest-api/index-apis/put-mapping.md index f949f173..bee331d5 100644 --- a/_opensearch/rest-api/index-apis/put-mapping.md +++ b/_opensearch/rest-api/index-apis/put-mapping.md @@ -34,10 +34,25 @@ PUT /sample-index/_mapping ## Path and HTTP methods +The index name is a required path parameter. If you don't specify the index, you will get an error. + ``` PUT //_mapping -PUT /_mapping ``` +For example, to create a mapping for the `sample-index` index, you can make the following call to the mapping API operation: + +``` +PUT /sample-index/_mapping/ +{ + "properties":{ + "year":{ + "type": "text" + } + } +} +``` + +Upon success, you will receive `acknowledged" : true` in the response. You can also use the put mapping operation to update multiple indexes with one request. From 4e6150e5eef7b0a8f1df53d61dbdb00888d7eaaf Mon Sep 17 00:00:00 2001 From: alicejw Date: Thu, 26 May 2022 15:06:09 -0700 Subject: [PATCH 2/4] for updates Signed-off-by: alicejw --- .../rest-api/index-apis/put-mapping.md | 104 +++++++++--------- 1 file changed, 50 insertions(+), 54 deletions(-) diff --git a/_opensearch/rest-api/index-apis/put-mapping.md b/_opensearch/rest-api/index-apis/put-mapping.md index bee331d5..d9f0aaac 100644 --- a/_opensearch/rest-api/index-apis/put-mapping.md +++ b/_opensearch/rest-api/index-apis/put-mapping.md @@ -14,68 +14,19 @@ If you want to create or add mappings and fields to an index, you can use the pu 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 -```json -PUT /sample-index/_mapping +## Required path parameter -{ - "properties": { - "age": { - "type": "integer" - }, - "occupation":{ - "type": "text" - } - } -} -``` +The only required path parameter is the index with which to associate the mapping. If you don't specify an index, you will get an error. - -## Path and HTTP methods - -The index name is a required path parameter. If you don't specify the index, you will get an error. +You can specify a single index, or multiple indexes separated by a comma as follows: ``` PUT //_mapping -``` -For example, to create a mapping for the `sample-index` index, you can make the following call to the mapping API operation: - -``` -PUT /sample-index/_mapping/ -{ - "properties":{ - "year":{ - "type": "text" - } - } -} -``` - -Upon success, you will receive `acknowledged" : true` in the response. - -You can also use the put mapping operation to update multiple indexes with one request. - -``` PUT /,/_mapping ``` -## URL parameters - -All put mapping parameters are optional. - -Parameter | Data Type | Description -:--- | :--- | :--- -<target-index> | 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 don’t match any indexes. Default is `true`. -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 indexes in the response. -ignore_malformed | Boolean | Use this parameter with the `ip_range` data type to specify that OpenSearch should ignore malformed fields. If `true`, OpenSearch does not include entries that do not match the IP range specified in the index in the response. The default is `false`. -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 +## Required request body field The request body must contain `properties`, which has all of the mappings that you want to create or update. @@ -92,10 +43,55 @@ The request body must contain `properties`, which has all of the mappings that y } ``` -## Response +## Optional query parameters + +Optionally, you can add query parameters to fine tune your + +For example, to skip any missing or closed indexes in the response, you can add the `ignore_unavailable` query parameter to your request as follows: + +```json +PUT /sample-index/_mapping?ignore_unavailable +``` + +The following table defines the put mapping query parameters: + +Parameter | Data Type | Description +:--- | :--- | :--- +allow_no_indices | Boolean | Whether to ignore wildcards that don’t match any indexes. Default is `true`. +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 indexes in the response. +ignore_malformed | Boolean | Use this parameter with the `ip_range` data type to specify that OpenSearch should ignore malformed fields. If `true`, OpenSearch does not include entries that do not match the IP range specified in the index in the response. The default is `false`. +cluster_manager_timeout | Time | How long to wait for a connection to the cluster manager 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. + +#### Sample Request + +The following request creates a new mapping for the `sample-index` index: + +```json +PUT /sample-index/_mapping + +{ + "properties": { + "age": { + "type": "integer" + }, + "occupation":{ + "type": "text" + } + } +} +``` + +#### Sample Response + +Upon success, the response returns `"acknowledged": true`. ```json { "acknowledged": true } ``` + + From 9aba0c6e00df136c2b1846dadd4e6ee976507beb Mon Sep 17 00:00:00 2001 From: alicejw Date: Thu, 26 May 2022 15:20:04 -0700 Subject: [PATCH 3/4] for updates Signed-off-by: alicejw --- _opensearch/rest-api/index-apis/put-mapping.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/_opensearch/rest-api/index-apis/put-mapping.md b/_opensearch/rest-api/index-apis/put-mapping.md index d9f0aaac..fd4e0ea3 100644 --- a/_opensearch/rest-api/index-apis/put-mapping.md +++ b/_opensearch/rest-api/index-apis/put-mapping.md @@ -45,9 +45,7 @@ The request body must contain `properties`, which has all of the mappings that y ## Optional query parameters -Optionally, you can add query parameters to fine tune your - -For example, to skip any missing or closed indexes in the response, you can add the `ignore_unavailable` query parameter to your request as follows: +Optionally, you can add query parameters to make a more specific request. For example, to skip any missing or closed indexes in the response, you can add the `ignore_unavailable` query parameter to your request as follows: ```json PUT /sample-index/_mapping?ignore_unavailable From 9f6febed922eb41a48fba75ea7b70bd6b2115a66 Mon Sep 17 00:00:00 2001 From: alicejw Date: Thu, 26 May 2022 15:23:28 -0700 Subject: [PATCH 4/4] for format fix Signed-off-by: alicejw --- _opensearch/rest-api/index-apis/put-mapping.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/_opensearch/rest-api/index-apis/put-mapping.md b/_opensearch/rest-api/index-apis/put-mapping.md index fd4e0ea3..cf9390da 100644 --- a/_opensearch/rest-api/index-apis/put-mapping.md +++ b/_opensearch/rest-api/index-apis/put-mapping.md @@ -17,9 +17,7 @@ You can't use this operation to update mappings that already map to existing dat ## Required path parameter -The only required path parameter is the index with which to associate the mapping. If you don't specify an index, you will get an error. - -You can specify a single index, or multiple indexes separated by a comma as follows: +The only required path parameter is the index with which to associate the mapping. If you don't specify an index, you will get an error. You can specify a single index, or multiple indexes separated by a comma as follows: ``` PUT //_mapping