-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Make PreBuiltAnalyzerProviderFactory plugable via AnalysisPlugin and #31095
Make PreBuiltAnalyzerProviderFactory plugable via AnalysisPlugin and #31095
Conversation
Pinging @elastic/es-search-aggs |
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 left a few minor things but I'm marking this "request changes" because I'm confused about how closing works with PreBuiltAnalyzers.
Map<String, PreConfiguredTokenFilter> preConfiguredTokenFilters, | ||
Map<String, PreConfiguredTokenizer> preConfiguredTokenizers) { | ||
Map<String, PreBuiltAnalyzerProviderFactory> analyzerProviderFactories = new HashMap<>(); | ||
Map<String, PreConfiguredCharFilter> preConfiguredCharFilters, |
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 the old indentation was better here.
return new PreBuiltAnalyzerProvider(name, AnalyzerScope.INDICES, analyzer); | ||
} | ||
public PreBuiltAnalyzerProviderFactory(String name, Function<Version, Analyzer> create) { | ||
this(name, PreBuiltCacheFactory.CachingStrategy.LUCENE, create); |
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 it'd be nice to remove this second ctor so we're explicit every time.
} | ||
|
||
public Analyzer analyzer() { | ||
return analyzerProvider.get(); | ||
private static class PreBuiltAnalyzersDelegateCache implements PreBuiltCacheFactory.PreBuiltCache<AnalyzerProvider<?>> { |
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 this is worth some javadoc and comments to explain why we do it. It makes sense but things like an empty put
method will confuse future me when I read this class in six months.
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.
It'd be super nice to explain that we only need this because of PreBuiltAnalyzers
.
throws IOException { | ||
return create(name, settings); | ||
public void close() throws IOException { | ||
IOUtils.close((Closeable) cache.values().stream().map(AnalyzerProvider::get)); |
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.
It looks to me like this will hit a NullPointerException
.
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.
When you use it with an instance of PreBuiltAnalyzers
.
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.
good catch. I will fix that.
@@ -162,6 +161,16 @@ public AnalysisRegistry getAnalysisRegistry() { | |||
return tokenFilters; | |||
} | |||
|
|||
static Map<String, PreBuiltAnalyzerProviderFactory> setPreBuiltAnalyzerProviderFactory(List<AnalysisPlugin> plugins) { |
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.
setupPreBuiltAnalyzerProviderFactories
?
Thanks @nik9000 for reviewing. I've updated this PR. |
move `finger_print`, `pattern` and `standard_html_strip` analyzers to analysis-common module. (both AnalysisProvider and PreBuiltAnalyzerProvider) Changed PreBuiltAnalyzerProviderFactory to extend from PreConfiguredAnalysisComponent and changed to make sure that predefined analyzers are always instantiated with the current ES version and if an instance is requested for a different version then delegate to PreBuiltCache. This is similar to the behaviour that exists today in AnalysisRegistry.PreBuiltAnalysis and PreBuiltAnalyzerProviderFactory. Relates to elastic#23658
506bdcc
to
97f7539
Compare
move `finger_print`, `pattern` and `standard_html_strip` analyzers to analysis-common module. (both AnalysisProvider and PreBuiltAnalyzerProvider) Changed PreBuiltAnalyzerProviderFactory to extend from PreConfiguredAnalysisComponent and changed to make sure that predefined analyzers are always instantiated with the current ES version and if an instance is requested for a different version then delegate to PreBuiltCache. This is similar to the behaviour that exists today in AnalysisRegistry.PreBuiltAnalysis and PreBuiltAnalyzerProviderFactory. (#31095) Relates to #23658
move
finger_print
,pattern
andstandard_html_strip
analyzersto analysis-common module. (both AnalysisProvider and PreBuiltAnalyzerProvider)
Changed PreBuiltAnalyzerProviderFactory to extend from PreConfiguredAnalysisComponent and
changed to make sure that predefined analyzers are always instantiated with the current
ES version and if an instance is requested for a different version then delegate to PreBuiltCache.
This is similar to the behaviour that exists today in AnalysisRegistry.PreBuiltAnalysis and
PreBuiltAnalyzerProviderFactory.
Relates to #23658