# Elastic REST 6.4 IndexShrink Error

**URL:** <https://discuss.elastic.co/t/elastic-rest-6-4-indexshrink-error/146991>\
**Category:** Elasticsearch\
**Created:** [September 2, 2018, 6:58pm UTC](https://discuss.elastic.co/t/elastic-rest-6-4-indexshrink-error/146991 "2018-09-02T18:58:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![questar](https://avatars.discourse-cdn.com/v4/letter/q/9fc29f/32.png) [@questar](https://discuss.elastic.co/u/questar)\
**Post date:** [September 2, 2018, 6:58pm UTC](https://discuss.elastic.co/t/elastic-rest-6-4-indexshrink-error/146991/1 "2018-09-02T18:58:37Z")

</div>

Index built with:  
{"settings":{"number\_of\_shards":"1","number\_of\_routing\_shards":"2","number\_of\_replicas":"0"}}

ResizeRequest request = new ResizeRequest("code-000001", "code-000002");  
Settings settings = Settings.builder()  
.put("index.number\_of\_shards", 2)  
.put("index.blocks.write", true)  
.build();  
request.setCopySettings(true); // used in CURL doc, no affect on error  
request.getTargetIndexRequest().settings(settings); // tried via map also   
request.getTargetIndexRequest().alias(new Alias("alias1"));  
resizeResponse = ElasticDoc.getRestClient().indices().split(request, RequestOptions.DEFAULT);

Get following error:  
//{"error":{"root\_cause":[{"type":"illegal\_state\_exception","reason":"index code-000001 must be read-only to resize index. use "index.blocks.write=true""}],"type":"illegal\_state\_exception","reason":"index code-000001 must be read-only to resize index. use "index.blocks.write=true""},"status":500}

Environment: Windows 10, 1.8.0\_171 JDK

---

<div class="post-metadata">

**Author:** ![questar](https://avatars.discourse-cdn.com/v4/letter/q/9fc29f/32.png) [@questar](https://discuss.elastic.co/u/questar)\
**Post date:** [September 3, 2018, 3:07pm UTC](https://discuss.elastic.co/t/elastic-rest-6-4-indexshrink-error/146991/2 "2018-09-03T15:07:23Z")

</div>

Forgot to mention that the collection inside the Setting instance only shows one instance, so the second put is stepping on the first. Also tried using maps to the same effect.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [September 3, 2018, 3:16pm UTC](https://discuss.elastic.co/t/elastic-rest-6-4-indexshrink-error/146991/3 "2018-09-03T15:16:18Z")

</div>

> [@questar](#):
>
> "reason":"index code-000001 must be read-only to resize index. use "index.blocks.write=true""

This error message indicates that you may have missed a step in the [instructions](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/indices-shrink-index.html), which is to make sure the index is in read-only mode.

---

<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:** [October 1, 2018, 3:16pm UTC](https://discuss.elastic.co/t/elastic-rest-6-4-indexshrink-error/146991/4 "2018-10-01T15:16:24Z")

</div>

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