Skip to content

Commit

Permalink
HSEARCH-2584 Provide built-in analyzers with Lucene
Browse files Browse the repository at this point in the history
They same are provided by default by ES
  • Loading branch information
fax4ever authored and yrodiere committed Oct 23, 2020
1 parent b415749 commit 7a4daf3
Showing 1 changed file with 14 additions and 0 deletions.
Expand Up @@ -11,18 +11,32 @@
import org.hibernate.search.engine.backend.analysis.AnalyzerNames;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.core.KeywordAnalyzer;
import org.apache.lucene.analysis.core.SimpleAnalyzer;
import org.apache.lucene.analysis.core.StopAnalyzer;
import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
import org.apache.lucene.analysis.en.EnglishAnalyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;

public final class LuceneDefaultAnalysisConfigurer implements LuceneAnalysisConfigurer {
public static final LuceneDefaultAnalysisConfigurer INSTANCE = new LuceneDefaultAnalysisConfigurer();

private final Analyzer standard = new StandardAnalyzer();
private final Analyzer simple = new SimpleAnalyzer();
private final Analyzer whitespace = new WhitespaceAnalyzer();
private final Analyzer stop = new StopAnalyzer( EnglishAnalyzer.ENGLISH_STOP_WORDS_SET );
private final Analyzer keyword = new KeywordAnalyzer();

private LuceneDefaultAnalysisConfigurer() {
}

@Override
public void configure(LuceneAnalysisConfigurationContext context) {
context.analyzer( AnalyzerNames.DEFAULT ).instance( standard );
context.analyzer( AnalyzerNames.STANDARD ).instance( standard );
context.analyzer( AnalyzerNames.SIMPLE ).instance( simple );
context.analyzer( AnalyzerNames.WHITESPACE ).instance( whitespace );
context.analyzer( AnalyzerNames.STOP ).instance( stop );
context.analyzer( AnalyzerNames.KEYWORD ).instance( keyword );
}
}

0 comments on commit 7a4daf3

Please sign in to comment.