# How to specify number\_of\_shards when putting data into ES using elasticsearch-hadoop SDK

**URL:** https://discuss.elastic.co/t/how-to-specify-number-of-shards-when-putting-data-into-es-using-elasticsearch-hadoop-sdk/197001
**Category:** Elasticsearch
**Tags:** es-hadoop
**Created:** [August 27, 2019, 8:40pm UTC](https://discuss.elastic.co/t/how-to-specify-number-of-shards-when-putting-data-into-es-using-elasticsearch-hadoop-sdk/197001 "2019-08-27T20:40:52Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![yuecong](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuecong/32/49061_2.png) [@yuecong](https://discuss.elastic.co/u/yuecong)
#### Post date: [August 27, 2019, 8:40pm UTC](https://discuss.elastic.co/t/how-to-specify-number-of-shards-when-putting-data-into-es-using-elasticsearch-hadoop-sdk/197001/1 "2019-08-27T20:40:53Z")

</div>

From this page for the elasticsearch hadoop SDK, I can not find how to configure number\_of\_shards when creating one index automatically like

> .option("es.resource.write", "log-{dateHour}")  
> In this doc, it menthioned it can use index setting API, but number\_of\_shards can only be set during index creation.

> **[Create index API | Elasticsearch Guide \[7.3\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/indices-create-index.html#create-index-settings)**

I tried  
.option("es.index.number\_of\_shards", 10)  
.option("es.index.refresh\_interval", 10)

but it does not looks like work, becuase when I query the index setting, the number\_of\_shards for the one created is still 1.

Thanks

---

<div class="post-metadata">

### Author: ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)
#### Post date: [August 27, 2019, 9:06pm UTC](https://discuss.elastic.co/t/how-to-specify-number-of-shards-when-putting-data-into-es-using-elasticsearch-hadoop-sdk/197001/2 "2019-08-27T21:06:24Z")

</div>

you have to set that in template

```
PUT _template/<name of template>
{
   "index_patterns" : ["*job*"],
   "order" : 1,
   "settings" : {
       "number_of_shards" : "3",
       "number_of_replicas" : "1"
   }
}

```

This is saying that any indexname which has word log will be created with 3 shard and 1 replicas

---

<div class="post-metadata">

### Author: ![yuecong](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuecong/32/49061_2.png) [@yuecong](https://discuss.elastic.co/u/yuecong)
#### Post date: [August 27, 2019, 11:09pm UTC](https://discuss.elastic.co/t/how-to-specify-number-of-shards-when-putting-data-into-es-using-elasticsearch-hadoop-sdk/197001/3 "2019-08-27T23:09:40Z")

</div>

Thanks so much for the suggestion. This is really helpful!

---

<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 24, 2019, 11:09pm UTC](https://discuss.elastic.co/t/how-to-specify-number-of-shards-when-putting-data-into-es-using-elasticsearch-hadoop-sdk/197001/4 "2019-09-24T23:09:40Z")

</div>

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