Allow to assign a name to an analyzer class/instance

Description

As highlighted in this SO question: http://stackoverflow.com/questions/40928584/use-existing-analyzer-in-hibernate-search-analyzerdiscriminator

Not being able to associated an existing Analyzer class, for example org.apache.lucene.analysis.cjk.CJKAnalyzer to a "definition name", preculeds it from being used in some contexts, for example via @AnalyzerDiscriminator.

We have several alternative solutions.

  • allow @AnalyzerDef to refer to an Analyzer class (how to handle the either/or of the various attributes? looks bad).

  • allow the discriminator to return the class instance (horrible, and doesn't resolve the problem for possible other needs of named analyzers)

  • allow defining name/class pairs in the configuration properties?

I think I prefer the 3rd option, but I also have the feeling that @AnalyzerDef isn't "complete" without this capability as it's not symmetric with the dual-capability of @Analyzer.

Activity

Show:

Yoann Rodière March 28, 2019 at 4:03 PM

Solved in Search 6, you can just name an instance of that analyzer in your LuceneAnalysisConfigurer:

context.analyzer( "analyzerName" ).instance( new StandardAnalyzer() );

See org.hibernate.search.integrationtest.showcase.library.analysis.LuceneLibraryAnalysisConfigurer

Fixed

Details

Assignee

Reporter

Components

Fix versions

Priority

Created December 15, 2016 at 11:08 PM
Updated April 4, 2019 at 9:41 AM
Resolved March 28, 2019 at 4:03 PM