-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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 analysis plugins fails #5034
Conversation
@@ -401,4 +401,13 @@ public synchronized Analyzer getAnalyzer(Version version) { | |||
return analyzer; | |||
} | |||
|
|||
static public PreBuiltAnalyzers valueOf(String name, PreBuiltAnalyzers defaultAnalyzer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we just delegate to valueOf
and if it throws an exception we return the default? I don't think we should do the linear checks here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also name it get
or getOrDefault
It looks pretty cool though. now the hard part comes... can you write a test for it? We have the ability to set the index version in the settings so you could write a test that loads a dummy pluging that registers the prebuild stuff and create the index with a mapping and a different index version. There are many utils for this like
|
Great! I was wondering how to test it automatically! Going to look at this. |
@s1monw Could you review it please? Tests fails without the patch and works when I apply the patch |
@Inject | ||
public DummyIndicesAnalysis(Settings settings, IndicesAnalysisService indicesAnalysisService) { | ||
super(settings); | ||
indicesAnalysisService.analyzerProviderFactories().put("dummy", new PreBuiltAnalyzerProviderFactory("dummy", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks awesome! exactly what I expected
can you also try to add prebuild TokenFitler and Tokenizer? just for kicks
@s1monw PR updated with test and headers updated. I think we are good now. |
* See https://github.com/elasticsearch/elasticsearch/issues/5030 | ||
*/ | ||
@Test | ||
public void testThatPluginAnalyzersCanBeUpdated() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm why did you remove the mapping from here? I think that was a good change?
you should add the settings from from public Settings indexSettings()
are only used if you use prepareCreate
so you should add the settings to the versionSettings below.
other than that it looks awesome
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I ran the test without the patch and without the mapping and it was failing. So I guess that this analyzer is set by default when creating the index. So we don't need to set it on a specific field to reproduce the issue.
That said I can add the mapping again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About indexSettings()
, this is true. I added to versionSettings
and I have now an error which I need to fix. Will push a new update soon.
When an analysis plugins provides default index settings using `PreBuiltAnalyzerProviderFactory`, `PreBuiltTokenFilterFactoryFactory` or `PreBuiltTokenizerFactoryFactory` it fails when upgrading it with elasticsearch superior or equal to 0.90.5. Related issue: elastic#4936 Fix is needed in core. But, in the meantime, analysis plugins developers can fix that issue by overloading default prebuilt factories. For example: ```java public class StempelAnalyzerProviderFactory extends PreBuiltAnalyzerProviderFactory { private final PreBuiltAnalyzerProvider analyzerProvider; public StempelAnalyzerProviderFactory(String name, AnalyzerScope scope, Analyzer analyzer) { super(name, scope, analyzer); analyzerProvider = new PreBuiltAnalyzerProvider(name, scope, analyzer); } @OverRide public AnalyzerProvider create(String name, Settings settings) { return analyzerProvider; } public Analyzer analyzer() { return analyzerProvider.get(); } } ``` And instead of: ```java @Inject public PolishIndicesAnalysis(Settings settings, IndicesAnalysisService indicesAnalysisService) { super(settings); indicesAnalysisService.analyzerProviderFactories().put("polish", new PreBuiltAnalyzerProviderFactory("polish", AnalyzerScope.INDICES, new PolishAnalyzer(Lucene.ANALYZER_VERSION))); } ``` do ```java @Inject public PolishIndicesAnalysis(Settings settings, IndicesAnalysisService indicesAnalysisService) { super(settings); indicesAnalysisService.analyzerProviderFactories().put("polish", new StempelAnalyzerProviderFactory("polish", AnalyzerScope.INDICES, new PolishAnalyzer(Lucene.ANALYZER_VERSION))); } ``` Closes elastic#5030
David this looks great +1 to push |
When an analysis plugins provides default index settings using
PreBuiltAnalyzerProviderFactory
,PreBuiltTokenFilterFactoryFactory
,PreBuiltTokenizerFactoryFactory
orPreBuiltCharFilterFactoryFactory
it fails when upgrading it with elasticsearch superior or equal to 0.90.5.Related issue: #4936
Fix is needed in core. But, in the meantime, analysis plugins developers can fix that issue by overloading default prebuilt factories.
For example:
And instead of:
do
Closes #5030