# How to issue \_optimize on Elastic Cloud

**URL:** <https://discuss.elastic.co/t/how-to-issue-optimize-on-elastic-cloud/131235>\
**Category:** Elasticsearch\
**Created:** [May 10, 2018, 12:00am UTC](https://discuss.elastic.co/t/how-to-issue-optimize-on-elastic-cloud/131235 "2018-05-10T00:00:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrubin](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@mrubin](https://discuss.elastic.co/u/mrubin)\
**Post date:** [May 10, 2018, 12:00am UTC](https://discuss.elastic.co/t/how-to-issue-optimize-on-elastic-cloud/131235/1 "2018-05-10T00:00:43Z")

</div>

I am trying to issue an \_optimize command via curl. I've tried both of the below styles:

```
$ curl --user username:password -XPOST "https://redacted.us-east-1.aws.found.io:9243/foo/_optimize?max_num_segments=1"
{"error":{"root_cause":[{"type":"parse_exception","reason":"request body is required"}],"type":"parse_exception","reason":"request 

$ curl --user username:password -H 'Content-Type: application/json' -XPOST https://redacted.us-east-1.aws.found.io:9243/foo/_optimize -d '{"max_num_segments" : "1"}'
{"error":{"root_cause":[{"type":"invalid_type_name_exception","reason":"Document mapping type name can't start with '_', found: [_optimize]"}],"type":"invalid_type_name_exception","reason":"Document mapping type name can't start with '_', found: [_optimize]"},"status":400}

```

Is \_optimize supported on the Elastic Cloud version of Elasticsearch?

---

<div class="post-metadata">

**Author:** ![shanec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shanec/32/4004_2.png) [@shanec](https://discuss.elastic.co/u/shanec)\
**Post date:** [May 10, 2018, 12:25am UTC](https://discuss.elastic.co/t/how-to-issue-optimize-on-elastic-cloud/131235/2 "2018-05-10T00:25:10Z")

</div>

The `_optimize` endpoint was [deprecated in Elasticsearch 2.1](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/indices-optimize.html) and [subsequently removed in Elasticsearch 5.0](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/breaking_50_rest_api_changes.html#_literal__optimize_literal_endpoint_removed). It was replaced by `_forcemerge` which more accurately describes what it's doing. Replace `_optimize` with `_forcemerge` and if you want to read more, have a look at the [force merge API documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html#indices-forcemerge)

---

<div class="post-metadata">

**Author:** ![mrubin](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@mrubin](https://discuss.elastic.co/u/mrubin)\
**Post date:** [May 11, 2018, 5:34pm UTC](https://discuss.elastic.co/t/how-to-issue-optimize-on-elastic-cloud/131235/3 "2018-05-11T17:34:49Z")

</div>

@shanec Is it still recommended to run `_forcemerge` on indexes that you know will no longer be added to, to set the # of segments to 1?

---

<div class="post-metadata">

**Author:** ![shanec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shanec/32/4004_2.png) [@shanec](https://discuss.elastic.co/u/shanec)\
**Post date:** [May 13, 2018, 2:11am UTC](https://discuss.elastic.co/t/how-to-issue-optimize-on-elastic-cloud/131235/4 "2018-05-13T02:11:27Z")

</div>

Elasticsearch will automatically merge segments in the background for you. If you want to explicitly do so at an optimal time, \_forcemerge can be useful. But to be honest, most users don't need to explicitly call forcemerge.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 10, 2018, 2:11am UTC](https://discuss.elastic.co/t/how-to-issue-optimize-on-elastic-cloud/131235/5 "2018-06-10T02:11:27Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
