# Split Index Help Required

**URL:** <https://discuss.elastic.co/t/split-index-help-required/163978>\
**Category:** Elasticsearch\
**Created:** [January 12, 2019, 4:33am UTC](https://discuss.elastic.co/t/split-index-help-required/163978 "2019-01-12T04:33:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nuwancs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nuwancs/32/46419_2.png) [@nuwancs](https://discuss.elastic.co/u/nuwancs)\
**Post date:** [January 12, 2019, 4:33am UTC](https://discuss.elastic.co/t/split-index-help-required/163978/1 "2019-01-12T04:33:06Z")

</div>

I am trying to reindex my index with following commands. And I get an error.  
source - transactions-reindexed-2018.12.03-01

```
PUT t2
{
    "settings": {
        "index.number_of_shards" : 5,
        "index.number_of_routing_shards" : 100 
    }
}

PUT /transactions-reindexed-2018.12.03-01/_settings
{
  "settings": {
    "index.blocks.write": true 
  }
}

POST transactions-reindexed-2018.12.03-01/_split/t2
{
  "settings": {
    "index.number_of_shards": 10
  }
}

```

**Error**

> ```
> {
> "error": {
> "root_cause": [
> {
> "type": "illegal_state_exception",
> "reason": "the number of routing shards [5] must be a multiple of the target shards [10]"
> }
> ],
> "type": "illegal_state_exception",
> "reason": "the number of routing shards [5] must be a multiple of the target shards [10]"
> },
> "status": 500
> }
> 
> ```

**Index Info**

> Health:  
> green  
> Status:  
> open  
> Primaries:  
> 5  
> Replicas:  
> 1  
> Docs Count:  
> 54350414  
> Docs Deleted:  
> 0  
> Storage Size:  
> 4gb  
> Primary Storage Size:  
> 2gb

---

<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:** [January 13, 2019, 11:14am UTC](https://discuss.elastic.co/t/split-index-help-required/163978/2 "2019-01-13T11:14:58Z")

</div>

It looks like you have mixed up the source and destination indices. I believe it should look like this:

```auto
PUT t2
{
  "settings": {
    "index.number_of_shards" : 5,
    "index.number_of_routing_shards" : 100
  }
}

PUT /t2/_settings
{
  "settings": {
    "index.blocks.write": true
  }
}

POST t2/_split/transactions-reindexed-2018.12.03-01
{
  "settings": {
    "index.number_of_shards": 10
  }
}

```

---

<div class="post-metadata">

**Author:** ![nuwancs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nuwancs/32/46419_2.png) [@nuwancs](https://discuss.elastic.co/u/nuwancs)\
**Post date:** [January 14, 2019, 5:34am UTC](https://discuss.elastic.co/t/split-index-help-required/163978/3 "2019-01-14T05:34:03Z")

</div>

Thanx Christian,  
When I ran as you instructed, got following error,

```
{
  "error": {
    "root_cause": [
      {
        "type": "resource_already_exists_exception",
        "reason": "index [transactions-reindexed-2018.12.03-01/cNqlGSmwTt-pa_LYvkGyeQ] already exists",
        "index_uuid": "cNqlGSmwTt-pa_LYvkGyeQ",
        "index": "transactions-reindexed-2018.12.03-01"
      }
    ],
    "type": "resource_already_exists_exception",
    "reason": "index [transactions-reindexed-2018.12.03-01/cNqlGSmwTt-pa_LYvkGyeQ] already exists",
    "index_uuid": "cNqlGSmwTt-pa_LYvkGyeQ",
    "index": "transactions-reindexed-2018.12.03-01"
  },
  "status": 400
}
```

---

<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:** [January 14, 2019, 5:40am UTC](https://discuss.elastic.co/t/split-index-help-required/163978/4 "2019-01-14T05:40:26Z")

</div>

I think that error message is quite clear. You can not create the new index as it already exists.

---

<div class="post-metadata">

**Author:** ![nuwancs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nuwancs/32/46419_2.png) [@nuwancs](https://discuss.elastic.co/u/nuwancs)\
**Post date:** [January 14, 2019, 9:06am UTC](https://discuss.elastic.co/t/split-index-help-required/163978/5 "2019-01-14T09:06:16Z")

</div>

i wanna split my "transactions-reindexed-2018.12.03-01" index with 5 shards to 10 shards.  
I don't have an index named t2 till I create using the 1 step of the split command.  
What I am doing wrong here?

---

<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:** [January 14, 2019, 9:13am UTC](https://discuss.elastic.co/t/split-index-help-required/163978/6 "2019-01-14T09:13:35Z")

</div>

The index you want to split (`t2` in the example) must have been created with `index.number_of_routing_shards` set. If you are looking to split `transactions-reindexed-2018.12.03-01` into a new index named `t2` you will need to swap the index names in the example I provided. If the index you want to split was not created with the `index.number_of_routing_shards` parameter, split will not work and you instead need to reindex.

It looks like this is an hourly index. How much data does it contain as you are considering a split? Keep in mind that [having lots of small indices and shards can be very inefficient and affect performance](https://www.elastic.co/blog/how-many-shards-should-i-have-in-my-elasticsearch-cluster).

---

<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:** [February 11, 2019, 9:27am UTC](https://discuss.elastic.co/t/split-index-help-required/163978/7 "2019-02-11T09:27:17Z")

</div>

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