From 4c4837d54dfa874a610f0d55321f6c81de784585 Mon Sep 17 00:00:00 2001 From: gaobinlong Date: Fri, 22 Mar 2024 05:00:42 +0800 Subject: [PATCH] Add force-merge API supports primary_only parameter (#6664) * Force-merge API supports primary_only parameter Signed-off-by: gaobinlong * Fix typo Signed-off-by: gaobinlong * Fix typo Signed-off-by: gaobinlong * Fix vale failure Signed-off-by: gaobinlong * Refine the wording Signed-off-by: gaobinlong * Update _api-reference/index-apis/force-merge.md Co-authored-by: Nathan Bower Signed-off-by: Melissa Vagi --------- Signed-off-by: gaobinlong Signed-off-by: Melissa Vagi Co-authored-by: Melissa Vagi Co-authored-by: Nathan Bower --- _api-reference/index-apis/force-merge.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/_api-reference/index-apis/force-merge.md b/_api-reference/index-apis/force-merge.md index 6ad2e7f23c5..6c2a61bef39 100644 --- a/_api-reference/index-apis/force-merge.md +++ b/_api-reference/index-apis/force-merge.md @@ -72,6 +72,7 @@ The following table lists the available query parameters. All query parameters a | `ignore_unavailable` | Boolean | If `true`, OpenSearch ignores missing or closed indexes. If `false`, OpenSearch returns an error if the force merge operation encounters missing or closed indexes. Default is `false`. | | `max_num_segments` | Integer | The number of larger segments into which smaller segments are merged. Set this parameter to `1` to merge all segments into one segment. The default behavior is to perform the merge as necessary. | | `only_expunge_deletes` | Boolean | If `true`, the merge operation only expunges segments containing a certain percentage of deleted documents. The percentage is 10% by default and is configurable in the `index.merge.policy.expunge_deletes_allowed` setting. Prior to OpenSearch 2.12, `only_expunge_deletes` ignored the `index.merge.policy.max_merged_segment` setting. Starting with OpenSearch 2.12, using `only_expunge_deletes` does not produce segments larger than `index.merge.policy.max_merged_segment` (by default, 5 GB). For more information, see [Deleted documents](#deleted-documents). Default is `false`. | +| `primary_only` | Boolean | If set to `true`, then the merge operation is performed only on the primary shards of an index. This can be useful when you want to take a snapshot of the index after the merge is complete. Snapshots only copy segments from the primary shards. Merging the primary shards can reduce resource consumption. Default is `false`. | #### Example request: Force merge a specific index @@ -101,6 +102,13 @@ POST /.testindex-logs/_forcemerge?max_num_segments=1 ``` {% include copy-curl.html %} +#### Example request: Force merge primary shards + +```json +POST /.testindex-logs/_forcemerge?primary_only=true +``` +{% include copy-curl.html %} + #### Example response ```json