Stable Plugin API module and analysis interfaces#88775
Stable Plugin API module and analysis interfaces#88775pgomulka merged 19 commits intoelastic:mainfrom
Conversation
This commit adds stable plugin API module and introduces analysis components interfaces and annotations. Stable plugin API is influenced by org.elasticserach.index.analysis classes. It allows to remove the server dependency from plugins.
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
|
Hi @pgomulka, I've created a changelog YAML for you. |
romseygeek
left a comment
There was a problem hiding this comment.
The API looks sensible to me. Is the plan to add this to a branch and then start migrating our internal components to use these factories?
| * Returns a lucene org.apache.lucene.analysis.Analyzer instance | ||
| */ | ||
| T create(); | ||
|
|
There was a problem hiding this comment.
I think we'll need getAnalysisMode on here as well.
@romseygeek we want merge this API and infrastructure to main branch. This will be followed by example plugins implementing this API and possibly some of analysis plugins we have in our repo (we did a PoC with nori) |
| dependencies { | ||
| api "org.apache.lucene:lucene-core:${versions.lucene}" | ||
| api "org.apache.lucene:lucene-analysis-common:${versions.lucene}" | ||
| api "org.apache.lucene:lucene-analysis-common:${versions.lucene}" |
There was a problem hiding this comment.
duplicate api dependency?
|
|
||
| module org.elasticsearch.analysis.plugin.api { | ||
| requires org.apache.lucene.core; | ||
| requires org.elasticsearch.plugin.api; |
There was a problem hiding this comment.
I noticed that there is no requires on lucene analysis common (which is in the Gradle dependencies)? Maybe it can be removed from the Gradle api dependency?
There was a problem hiding this comment.
good point, I am not sure why I needed this in the PoC branch. We can always add it back when needed
libs/plugin-analysis-api/src/main/java/org/elasticsearch/plugin/analysis/api/AnalysisMode.java
Show resolved
Hide resolved
| } | ||
| }; | ||
|
|
||
| private String readableName; |
There was a problem hiding this comment.
this field can be final, right?
...ugin-analysis-api/src/main/java/org/elasticsearch/plugin/analysis/api/CharFilterFactory.java
Show resolved
Hide resolved
| Reader create(Reader reader); | ||
|
|
||
| /** | ||
| * Normalize a tokenStream for use in multi-term queries |
There was a problem hiding this comment.
can we please end all sentences with a period/stop.
libs/plugin-api/src/main/java/org/elasticsearch/plugin/api/Nameable.java
Show resolved
Hide resolved
| @Target({ ElementType.TYPE }) | ||
| public @interface NamedComponent { | ||
| /** | ||
| * A name used for registration and lookup |
There was a problem hiding this comment.
Trivially, can we change this to the definitive article, "A name" -> "The name"
| * <ul> | ||
| * <li> The root package is org.elasticsearch.plugin</li> | ||
| * <li> Specialised API jars have their name following the root package. | ||
| * i.e. org.elasticsearch.analysis |
There was a problem hiding this comment.
This should be org.elasticsearch.plugin.analysis, right?
| * i.e. org.elasticsearch.analysis | ||
| * </li> | ||
| * <li> Interfaces and annotations used by plugin developers are in `api` package | ||
| * i.e org.elasticsearch.analysis.api or org.elasticsearch.api |
There was a problem hiding this comment.
o.e.plugin.analysis.api
There was a problem hiding this comment.
somehow I missed those comments.. I will fix this in #89772
| /** | ||
| * An analysis component used to create Analyzers. | ||
| */ | ||
| public interface AnalyzerFactory<T extends org.apache.lucene.analysis.Analyzer> extends Nameable { |
There was a problem hiding this comment.
Do we need the generic parameter here? The other factories are just returning a base type, which I think should be enough?
There was a problem hiding this comment.
agree, I don't think we need a generic here
This commit adds stable analysis plugin API with analysis components interfaces and annotations.
It does not contain any usage of it yet. Separate changes to introduce example plugins or refactoring to existing ones will follow later.
It contains two gradle modules. One
plugin-apiwith two annotations Nameable and NamedComponent, which can be reused for plugins other than analysis.And second
analysis-plugin-apiwhich contains analysis components (TokenFilterFactory, CharFilterFactory etc)NamedComponent - used by plugin developer - indicates that a Nameable component will be registered under a given name.
Nameable - for analysis plugins it is only used by the stable analysis api designers (ES) - indicates that component have a name and should be declared with NamedComponent
additional tasks that will follow: #88980