# Elaticsearch index shrink issue

**URL:** <https://discuss.elastic.co/t/elaticsearch-index-shrink-issue/97360>\
**Category:** Elasticsearch\
**Created:** [August 17, 2017, 8:04am UTC](https://discuss.elastic.co/t/elaticsearch-index-shrink-issue/97360 "2017-08-17T08:04:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sreejithps303](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sreejithps303/32/23868_2.png) [@sreejithps303](https://discuss.elastic.co/u/sreejithps303)\
**Post date:** [August 17, 2017, 8:04am UTC](https://discuss.elastic.co/t/elaticsearch-index-shrink-issue/97360/1 "2017-08-17T08:04:20Z")

</div>

Hi ,  
I am trying to shrink the indices in elasticsearch. Currenrly i have 5 primary shards and 1 replica .  
I want to change it to 1 primary and 1 replica shards.  
i have executed the steps mention in [Shrink Index | Elasticsearch Reference [5.5] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/indices-shrink-index.html)

But while shrinking i am getting below error. Anyone can help?

curl -XPOST -u xxxx:xxxxx 'xx.xx.xx.xx:9200/reporting-2017.08.12/\_shrink/reporting-2017.08.12-reindexed?pretty' -H 'Content-Type: application/json' -d'

> {  
> "settings": {  
> "index.number\_of\_replicas": 1,  
> "index.number\_of\_shards": 1,  
> "index.codec": "best\_compression"  
> }  
> }  
> '  
> {  
> "error" : {  
> "root\_cause" : [  
> {  
> "type" : "illegal\_argument\_exception",  
> "reason" : "mappings are not allowed when shrinking indices, all mappings are copied from the source index"  
> }  
> ],  
> "type" : "illegal\_argument\_exception",  
> "reason" : "mappings are not allowed when shrinking indices, all mappings are copied from the source index"  
> },  
> "status" : 400  
> }

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [August 17, 2017, 10:54am UTC](https://discuss.elastic.co/t/elaticsearch-index-shrink-issue/97360/2 "2017-08-17T10:54:51Z")

</div>

Do you have any index templates that match the new index name (`reporting-2017.08.12-reindexed`)? There's a bug that will be fixed in 5.6 that causes index templates to be applied to the new index ([https://github.com/elastic/elasticsearch/pull/25380](https://github.com/elastic/elasticsearch/pull/25380)).

In the meantime, you could make sure that the new index has a name that would not match the index template.

---

<div class="post-metadata">

**Author:** ![sreejithps303](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sreejithps303/32/23868_2.png) [@sreejithps303](https://discuss.elastic.co/u/sreejithps303)\
**Post date:** [August 17, 2017, 11:08am UTC](https://discuss.elastic.co/t/elaticsearch-index-shrink-issue/97360/3 "2017-08-17T11:08:37Z")

</div>

ok.. thanks , i will try with different name.

---

<div class="post-metadata">

**Author:** ![sreejithps303](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sreejithps303/32/23868_2.png) [@sreejithps303](https://discuss.elastic.co/u/sreejithps303)\
**Post date:** [August 17, 2017, 12:51pm UTC](https://discuss.elastic.co/t/elaticsearch-index-shrink-issue/97360/4 "2017-08-17T12:51:41Z")

</div>

It is working after i changed the target index name. thanks again,

---

<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:** [September 14, 2017, 12:51pm UTC](https://discuss.elastic.co/t/elaticsearch-index-shrink-issue/97360/5 "2017-09-14T12:51:44Z")

</div>

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