Example usage for org.apache.lucene.analysis.pl PolishAnalyzer PolishAnalyzer

List of usage examples for org.apache.lucene.analysis.pl PolishAnalyzer PolishAnalyzer

Introduction

In this page you can find the example usage for org.apache.lucene.analysis.pl PolishAnalyzer PolishAnalyzer.

Prototype

public PolishAnalyzer() 

Source Link

Document

Builds an analyzer with the default stop words: #DEFAULT_STOPWORD_FILE .

Usage

From source file:org.elasticsearch.indices.analysis.pl.PolishIndicesAnalysis.java

License:Apache License

@Inject
public PolishIndicesAnalysis(Settings settings, IndicesAnalysisService indicesAnalysisService) {
    super(settings);
    indicesAnalysisService.analyzerProviderFactories().put("polish",
            new PreBuiltAnalyzerProviderFactory("polish", AnalyzerScope.INDICES, new PolishAnalyzer()));

    indicesAnalysisService.tokenFilterFactories().put("polish_stem",
            new PreBuiltTokenFilterFactoryFactory(new TokenFilterFactory() {
                @Override//from  www .  j  a  v  a  2s . c  o  m
                public String name() {
                    return "polish_stem";
                }

                @Override
                public TokenStream create(TokenStream tokenStream) {
                    Trie tire;
                    try {
                        tire = StempelStemmer.load(
                                PolishAnalyzer.class.getResourceAsStream(PolishAnalyzer.DEFAULT_STEMMER_FILE));
                    } catch (IOException ex) {
                        throw new RuntimeException("Unable to load default stemming tables", ex);
                    }
                    return new StempelFilter(tokenStream, new StempelStemmer(tire));
                }
            }));
}