# Spring elastic search

**URL:** <https://discuss.elastic.co/t/spring-elastic-search/13885>\
**Category:** Elasticsearch\
**Created:** [October 9, 2013, 12:24pm UTC](https://discuss.elastic.co/t/spring-elastic-search/13885 "2013-10-09T12:24:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul1/32/46819_2.png) [@paul1](https://discuss.elastic.co/u/paul1)\
**Post date:** [October 9, 2013, 12:24pm UTC](https://discuss.elastic.co/t/spring-elastic-search/13885/1 "2013-10-09T12:24:26Z")

</div>

Hi ,

I am using \*spring-elasticsearch[https://github.com/dadoonet/spring-elasticsearch](https://github.com/dadoonet/spring-elasticsearch)  
\*I my configuration is

\_settings.json

{  
"index" : {  
"number\_of\_shards" : 3,  
"number\_of\_replicas" : 1  
}  
}

spring.xml

\<?xml version="1.0" encoding="UTF-8"?\>

\<elasticsearch:client id="esClient" esNodes="localhost:9300"  
properties="esproperties"  
autoscan="false" mappings="twitter/tweet" mergeSettings="true"mergeMapping="true"/\>

```
<util:properties id="esproperties" 

```

location="classpath:esclient-transport.properties"/\>

when i start the esClient 1st time it runs fine when i run the program  
again it throws exception as below this happens when i specify  
mergeSettings="true"

Exception in thread "main"  
org.springframework.beans.factory.BeanCreationException: Error creating  
bean with name 'esClient': Invocation of init method failed; nested  
exception is org.elasticsearch.ElasticSearchIllegalArgumentException: can't  
change the number of shards for an index

how to avoid this error . when should we use mergeSettings="true"

regards  
paul

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 9, 2013, 1:24pm UTC](https://discuss.elastic.co/t/spring-elastic-search/13885/2 "2013-10-09T13:24:58Z")

</div>

Hmmm…

I think I understand. Factory is first trying to create a new index with your settings (3,1) than after a restart tries to update settings but number of shards is immutable.  
Could you open an issue in spring-elasticsearch project?

I would like to find a fix for it.

## Thanks

David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 9 oct. 2013 à 14:24, paul [avinashpaul85@gmail.com](mailto:avinashpaul85@gmail.com) a écrit :

> Hi ,
> 
> I am using spring-elasticsearch I my configuration is
> 
> \_settings.json
> 
> {  
> "index" : {  
> "number\_of\_shards" : 3,  
> "number\_of\_replicas" : 1  
> }  
> }
> 
> spring.xml
> 
> \<?xml version="1.0" encoding="UTF-8"?\>
> 
> ```
> <!-- By default, you will get an Elasticsearch Transport Client connected to an Elasticsearch node already running at localhost:9300 using elasticsearch as cluster name -->
> <elasticsearch:client id="esClient" esNodes="localhost:9300" properties="esproperties"  
> autoscan="false" mappings="twitter/tweet" mergeSettings="true" mergeMapping="true"/>
> 
> <util:properties id="esproperties" location="classpath:esclient-transport.properties"/>
> 
> ```
> 
> when i start the esClient 1st time it runs fine when i run the program again it throws exception as below this happens when i specify mergeSettings="true"
> 
> Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'esClient': Invocation of init method failed; nested exception is org.elasticsearch.ElasticSearchIllegalArgumentException: can't change the number of shards for an index
> 
> how to avoid this error . when should we use mergeSettings="true"
> 
> regards  
> paul
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:13am UTC](https://discuss.elastic.co/t/spring-elastic-search/13885/3 "2017-07-06T02:13:12Z")

</div>

Closed on July 6, 2017, 2:13am UTC


