0

I am trying to change the number of shards and replicas for an index as shown below.. I am using ElasticSearch 2.4.0.

I did reindex the data and trying to change the number of shards and replicas with the new index.

For example if I want to reindex the bank data (screenshow below) - with 3 shards and 1 replica - how would I proceed?

enter image description here

Query:

 curl -XPUT http://localhost:9200/newbank -d'{ "settings": {
    "number_of_shards":2,
    "number_of_replicas":1
    }}'

Error:

{"error":{"root_cause":[{"type":"index_already_exists_exception","reason":"already exists","index":"newbank"}],"type":"index_already_exists_exception","reason":"already exists","index":"newbank"},"status":400}

Saw a similar kindof exception msg in elastic forum as well - which i have come across as well : https://discuss.elastic.co/t/elasticsearch-2-1-1-no-of-shard-settings/37825

Getting this error:

{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "can't change the number of shards for an index"
}
],
"type": "illegal_argument_exception",
"reason": "can't change the number of shards for an index"
},
"status": 400

Kindly help!

Thank you so much in advance.

Soundarya Thiagarajan
  • 574
  • 2
  • 13
  • 31
  • You need to delete the `newbank` index first, you cannot create a second index with the same name. – Val Sep 14 '16 at 12:13
  • my first index name was bank, reindexed one is newbank. should I delete bank one? – Soundarya Thiagarajan Sep 14 '16 at 12:16
  • The error is as clear as it gets: "index newbank already exists" – Val Sep 14 '16 at 12:18
  • run `curl -XDELETE http://localhost:9200/newbank` first and then you can try again – Val Sep 14 '16 at 12:19
  • how did you reindex ? you have to define setting when creating index – blackmamba Sep 14 '16 at 12:26
  • @val - how would I change the number of shards and replicas? I am facing the another issue : { "type": "illegal_argument_exception", "reason": "can't change the number of shards for an index" } ], – Soundarya Thiagarajan Sep 14 '16 at 12:49
  • You can only specify `number_of_shards` when creating a brand new index, if you call that on an existing index, it will not work. – Val Sep 14 '16 at 12:51
  • curl -XPOST 'localhost:9200/twitter/_bulk?pretty' @shakespeare.json -d '{"settings":{ "index":{ "number_of_shards":2, "number_of_replicas":1 } } }' Getting this error: "type" : "json_parse_exception", "reason" : "Unexpected character ('&' (code 38)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: [B@5307f567; line: 1, column: 2]" }, "status" : 500 – Soundarya Thiagarajan Sep 14 '16 at 13:31

0 Answers0