# How to change similarity settings runtime?

**URL:** https://discuss.elastic.co/t/how-to-change-similarity-settings-runtime/18639
**Category:** Elasticsearch
**Created:** [July 14, 2014, 4:11am UTC](https://discuss.elastic.co/t/how-to-change-similarity-settings-runtime/18639 "2014-07-14T04:11:36Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![spancer\_ray](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spancer_ray/32/76303_2.png) [@spancer\_ray](https://discuss.elastic.co/u/spancer_ray)
#### Post date: [July 14, 2014, 4:11am UTC](https://discuss.elastic.co/t/how-to-change-similarity-settings-runtime/18639/1 "2014-07-14T04:11:36Z")

</div>

Hi Guys,

I set my similarity type to 'BM25' in elasticsearch.yml , using index.similarity.default.type: BM25.  
But in my search case(searching across some indices), I have to use the default similarity type.  
Can I set the similarity type runtime without restarting the ES cluster? Or using java api to make  
settings take effect for specific indices or ES TransportClient?

I tried put settings in my java code while construct a TransportClient, using code like below:  
ImmutableSettings.settingsBuilder().put("index.similarity.custom.type", "default").build();

tried ‘index.similarity.default.type’， but it seems both 'index.similarity.default.type' and 'index.similarity.custom.type' didn't take effect while global settings in elasticsearch.yml is set.

Can anyone help?

Thanks a lot,  
Spancer

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [July 14, 2014, 7:00am UTC](https://discuss.elastic.co/t/how-to-change-similarity-settings-runtime/18639/2 "2014-07-14T07:00:36Z")

</div>

You can not change the similarity module of an index during runtime.

Jörg

On Monday, July 14, 2014 6:11:44 AM UTC+2, spancer ray wrote:

> Hi Guys,
> 
> I set my similarity type to 'BM25' in elasticsearch.yml , using  
> index.similarity.default.type: BM25.  
> But in my search case(searching across some indices), I have to use the  
> default similarity type.  
> Can I set the similarity type runtime without restarting the ES cluster?  
> Or  
> using java api to make  
> settings take effect for specific indices or ES TransportClient?
> 
> I tried put settings in my java code while construct a TransportClient,  
> using code like below:  
> ImmutableSettings.settingsBuilder().put("index.similarity.custom.type",  
> "default").build();
> 
> tried ‘index.similarity.default.type’， but it seems both  
> 'index.similarity.default.type' and 'index.similarity.custom.type' didn't  
> take effect while global settings in elasticsearch.yml is set.
> 
> Can anyone help?
> 
> Thanks a lot,  
> Spancer
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/How-to-change-similarity-settings-runtime-tp4059810.html](http://elasticsearch-users.115913.n3.nabble.com/How-to-change-similarity-settings-runtime-tp4059810.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/8cd6ee77-fc85-400f-a9b9-be551f02350b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8cd6ee77-fc85-400f-a9b9-be551f02350b%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)
#### Post date: [July 14, 2014, 6:17pm UTC](https://discuss.elastic.co/t/how-to-change-similarity-settings-runtime/18639/3 "2014-07-14T18:17:41Z")

</div>

Jörg is correct. In general, it would be a bad idea to change the  
similarity during runtime, but there are cases were it would be acceptable  
and the system should allow for those cases:

> <https://github.com/elastic/elasticsearch/issues/4403>
>
> The current code \[1\] does not allow changing a field's similarity via a mapping …update. While it is true that changing a similarity after an index has been created will probably cause havoc on the scoring, developers should have the flexibility to shoot their own foot. :) 
> 
> If I were to submit a patch to allow a configurable override of the current behavior, what is the possibility that it would be accepted? Do not want to write code if it will be denied.
> 
> \[1\] https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java?source=c#L526-L534

--  
Ivan

On Mon, Jul 14, 2014 at 12:00 AM, Jörg Prante [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:

> You can not change the similarity module of an index during runtime.
> 
> Jörg
> 
> On Monday, July 14, 2014 6:11:44 AM UTC+2, spancer ray wrote:
> 
> > Hi Guys,
> > 
> > I set my similarity type to 'BM25' in elasticsearch.yml , using  
> > index.similarity.default.type: BM25.  
> > But in my search case(searching across some indices), I have to use the  
> > default similarity type.  
> > Can I set the similarity type runtime without restarting the ES cluster?  
> > Or  
> > using java api to make  
> > settings take effect for specific indices or ES TransportClient?
> > 
> > I tried put settings in my java code while construct a TransportClient,  
> > using code like below:  
> > ImmutableSettings.settingsBuilder().put("index.similarity.custom.type",  
> > "default").build();
> > 
> > tried ‘index.similarity.default.type’， but it seems both  
> > 'index.similarity.default.type' and 'index.similarity.custom.type'  
> > didn't  
> > take effect while global settings in elasticsearch.yml is set.
> > 
> > Can anyone help?
> > 
> > Thanks a lot,  
> > Spancer
> > 
> > --  
> > View this message in context: [http://elasticsearch-users](http://elasticsearch-users).  
> > [115913.n3.nabble.com/How-to-change-similarity-settings-](http://115913.n3.nabble.com/How-to-change-similarity-settings-)  
> > runtime-tp4059810.html  
> > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/8cd6ee77-fc85-400f-a9b9-be551f02350b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8cd6ee77-fc85-400f-a9b9-be551f02350b%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/8cd6ee77-fc85-400f-a9b9-be551f02350b%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/8cd6ee77-fc85-400f-a9b9-be551f02350b%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQBeRhe2wMCisnuuetYTATs7aBZhp%2BRxcnsR\_GB5u5VaCQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQBeRhe2wMCisnuuetYTATs7aBZhp%2BRxcnsR_GB5u5VaCQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:15am UTC](https://discuss.elastic.co/t/how-to-change-similarity-settings-runtime/18639/4 "2017-07-06T01:15:54Z")

</div>


