# Upgrading index with custom similarity not working

**URL:** https://discuss.elastic.co/t/upgrading-index-with-custom-similarity-not-working/76678
**Category:** Elasticsearch
**Created:** [February 27, 2017, 6:40pm UTC](https://discuss.elastic.co/t/upgrading-index-with-custom-similarity-not-working/76678 "2017-02-27T18:40:46Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![xabbu42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xabbu42/32/44817_2.png) [@xabbu42](https://discuss.elastic.co/u/xabbu42)
#### Post date: [February 27, 2017, 6:40pm UTC](https://discuss.elastic.co/t/upgrading-index-with-custom-similarity-not-working/76678/1 "2017-02-27T18:40:46Z")

</div>

Hello

I use a custom similarity and since the switch to elasticsearch 5 I can't upgrade existing indices using this custom similarity.

The Plugin code registers the custom similarity as follows:

```
public void onIndexModule(IndexModule module) {
    module.addSimilarity("searchchsimilarity", SearchChSimilarityProvider::new);
}

```

And the indices use this similarity as default by setting:

```
"settings": {
    "similarity": {
        "default": {
            "type": "searchchsimilarity"
        }
    },

```

This works when creating new indices, but if I want to upgrade an index from an older elasticsearch version (either by restoring a snapshot or by starting a newer elasticsearch on the server), I get the following errors:

> <https://gist.github.com/xabbu42/66dd46bd3cc15244cede8ceadf884fd8>

What am I doing wrong? Or is this a bug?

---

<div class="post-metadata">

### Author: ![xabbu42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xabbu42/32/44817_2.png) [@xabbu42](https://discuss.elastic.co/u/xabbu42)
#### Post date: [March 2, 2017, 2:42pm UTC](https://discuss.elastic.co/t/upgrading-index-with-custom-similarity-not-working/76678/2 "2017-03-02T14:42:25Z")

</div>

No help here? There have to be others with the same problem. I'm happy to give more info if necessary or test some stuff.

---

<div class="post-metadata">

### Author: ![Peter\_van\_der\_Weerd](https://avatars.discourse-cdn.com/v4/letter/p/e99b99/32.png) [@Peter\_van\_der\_Weerd](https://discuss.elastic.co/u/Peter_van_der_Weerd)
#### Post date: [March 8, 2017, 9:12pm UTC](https://discuss.elastic.co/t/upgrading-index-with-custom-similarity-not-working/76678/3 "2017-03-08T21:12:04Z")

</div>

Hi Nathan,

I did not try to upgrade, but I expect it to fail. Elastic changed the way a similarity is configured, so it might or might not succeed.

Did you check the code? I mean from the stacktrace? The inner exception states that it cannot find your similarity…

It is AFAIK configurable afterwards via a put settings. So, you could try to remove the similarity in the old ES, open it in the new ES and re-apply the similarity.

A different approach would be to just reindex the complete index.

Hope this helps a bit.

Kind regards,  
Peter

---

<div class="post-metadata">

### Author: ![xabbu42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xabbu42/32/44817_2.png) [@xabbu42](https://discuss.elastic.co/u/xabbu42)
#### Post date: [March 9, 2017, 2:41pm UTC](https://discuss.elastic.co/t/upgrading-index-with-custom-similarity-not-working/76678/4 "2017-03-09T14:41:45Z")

</div>

> [@Peter\_van\_der\_Weerd](#):
>
> Did you check the code? I mean from the stacktrace? The inner exception states that it cannot find your similarity…

yeah, i've seen that. the strange thing is, that I can create a new index using the very same similarity name with no problems. thats why I think that either my way of registering a custom similarity is wrong or elasticsearch 5 has a bug here.

> [@Peter\_van\_der\_Weerd](#):
>
> It is AFAIK configurable afterwards via a put settings. So, you could try to remove the similarity in the old ES, open it in the new ES and re-apply the similarity.

Thats a good idea and I will probably do an upgrade this way next week. Still that was not necessary with elasticsearch 2.4.

Thanks a lot for your answer.  
Nathan

---

<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: [April 6, 2017, 2:42pm UTC](https://discuss.elastic.co/t/upgrading-index-with-custom-similarity-not-working/76678/5 "2017-04-06T14:42:13Z")

</div>

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