Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading an index using a custom similarity fails #25350

Closed
xabbu42 opened this issue Jun 22, 2017 · 6 comments
Closed

Upgrading an index using a custom similarity fails #25350

xabbu42 opened this issue Jun 22, 2017 · 6 comments
Labels
>bug :Core/Infra/Plugins Plugin API and infrastructure :Search/Search Search-related issues that do not fall into other categories

Comments

@xabbu42
Copy link
Contributor

xabbu42 commented Jun 22, 2017

Elasticsearch version: 5.1.1 - 5.4.1

Plugins installed: [analysis-icu, elasticsearch-position-similarity]

JVM version (java -version):
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (IcedTea 3.4.0) (suse-10.10.3-x86_64)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)

OS version (uname -a if on a Unix-like system):
Linux oviken 4.4.36-8-default #1 SMP Fri Dec 9 16:18:38 UTC 2016 (3ec5648) x86_64 x86_64 x86_64 GNU/Linux

Description of the problem including expected versus actual behavior:
Upgrading an index using a custom similarity fails in org.elasticsearch.cluster.metadata.MetaDataIndexUpgradeService.checkMappingsCompatibility with the exception "Unknown Similarity type". If the old and the new elasticserver have the same custom similarity installed, upgrading should work.

Looking at the code, it is no surprise that this does not work, as checkMappingsCompatibility creates a SimilarityService with an empty list of additional similarities. It seems something akin to the fake analyzerMap is necessary for custom similarities?

This is a follow up to https://discuss.elastic.co/t/upgrading-index-with-custom-similarity-not-working/76678 as by now I'm quite sure this is a bug with elasticsearch an not with my similarity plugin.

Steps to reproduce:

  1. Start elasticsearch version 5.1.1 with https://github.com/sdauletau/elasticsearch-position-similarity installed (I've attached the exact zip I build and used)
    elasticsearch-position-similarity-5.1.1.zip

  2. Create an index using this similarity:

curl -s -XPUT "http://localhost:9200/test_index" -d '
{
  "settings": {
    "similarity": {
      "positionSimilarity": {
        "type": "position-similarity"
      }
    }
  }
}'
  1. Stop elasticsearch, upgrade to 5.1.2, install the same plugin for this version (I again attached the zip I used)
    elasticsearch-position-similarity-5.1.2.zip

  2. Start elasticsearch again

Provide logs (if relevant):

elasticsearch.txt

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

@cbuescher cbuescher added >bug :Core/Infra/Plugins Plugin API and infrastructure and removed discuss labels Jun 23, 2017
@rjernst
Copy link
Member

rjernst commented Jun 29, 2017

This looks like a bug in how similarities are registered. Currently they are added inside Plugin.onIndexModule. But this is too late when the node is starting up with existing similarites in index settings.

I think we should move similarities out to a pull based plugin interface, and have the index get a registry of similarity impls. @s1monw wdyt?

@seekely
Copy link

seekely commented Aug 29, 2017

We ran into the same issue when trying to upgrade from 2.3 to 5.2 (both in place and from snapshot). We were thinking of patching and building ourselves, but a proper fix did not look very straight forward to our unfamiliar eyes since the similarities are not loaded until an IndexService is created and that looked a little tough to just mock/fake in this scenario.

@xabbu42
Copy link
Contributor Author

xabbu42 commented Sep 5, 2017

I was also planning to try a patch myself using a similar workaround as is already done with analyzers in checkMappingsCompatibility. But the comments of rjernst suggest that the problem is more complex and so I'm waiting on further input before trying anything myself.

@rjernst
Copy link
Member

rjernst commented Sep 7, 2017

@xabbu42 I think your idea of using a similar workaround as we do with analyzers is the correct solution. My earlier comment was missing some context and would be something nice to have, but is a separate issue.

@pweerd
Copy link

pweerd commented Sep 14, 2017

In general, I would advocate a settings that allows an index with a problematic custom similarity to be loaded anyway (with kind of a no-op similarity). This enables us to manipulate the index-definition afterwards.

rjernst pushed a commit that referenced this issue Jan 9, 2018
Use a fake similarity map that always returns a value in MetaDataIndexUpgradeService.checkMappingsCompatibility instead of an empty map.

Closes #25350
rjernst pushed a commit that referenced this issue Jan 9, 2018
Use a fake similarity map that always returns a value in MetaDataIndexUpgradeService.checkMappingsCompatibility instead of an empty map.

Closes #25350
@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Similarities labels Feb 14, 2018
@thomas11
Copy link
Contributor

@rjernst I'd like to have this fix in the 5.x branch as well. I've ported it and it works for me locally. Can I open a PR?

thomas11 pushed a commit to thomas11/elasticsearch that referenced this issue Feb 22, 2018
Fix upgrading indices which use a custom similarity plugin.
Use a fake similarity map that always returns a value in
MetaDataIndexUpgradeService.checkMappingsCompatibility instead of
an empty map.
rjernst pushed a commit that referenced this issue Mar 1, 2018
Use a fake similarity map that always returns a value in MetaDataIndexUpgradeService.checkMappingsCompatibility instead of an empty map.

Closes #25350
relates #26985
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Core/Infra/Plugins Plugin API and infrastructure :Search/Search Search-related issues that do not fall into other categories
Projects
None yet
Development

No branches or pull requests

8 participants