Search in sources :

Example 1 with AnalysisUkrainianPlugin

use of org.elasticsearch.plugin.analysis.ukrainian.AnalysisUkrainianPlugin in project elasticsearch by elastic.

the class SimpleUkrainianAnalyzerTests method testAnalyzer.

private static void testAnalyzer(String source, String... expected_terms) throws IOException {
    TestAnalysis analysis = createTestAnalysis(new Index("test", "_na_"), Settings.EMPTY, new AnalysisUkrainianPlugin());
    Analyzer analyzer = analysis.indexAnalyzers.get("ukrainian").analyzer();
    TokenStream ts = analyzer.tokenStream("test", source);
    CharTermAttribute term1 = ts.addAttribute(CharTermAttribute.class);
    ts.reset();
    for (String expected : expected_terms) {
        assertThat(ts.incrementToken(), equalTo(true));
        assertThat(term1.toString(), equalTo(expected));
    }
    assertThat(ts.incrementToken(), equalTo(false));
}
Also used : TokenStream(org.apache.lucene.analysis.TokenStream) CharTermAttribute(org.apache.lucene.analysis.tokenattributes.CharTermAttribute) Index(org.elasticsearch.index.Index) Analyzer(org.apache.lucene.analysis.Analyzer) AnalysisUkrainianPlugin(org.elasticsearch.plugin.analysis.ukrainian.AnalysisUkrainianPlugin)

Example 2 with AnalysisUkrainianPlugin

use of org.elasticsearch.plugin.analysis.ukrainian.AnalysisUkrainianPlugin in project elasticsearch by elastic.

the class UkrainianAnalysisTests method testDefaultsUkranianAnalysis.

public void testDefaultsUkranianAnalysis() throws IOException {
    final TestAnalysis analysis = createTestAnalysis(new Index("test", "_na_"), Settings.EMPTY, new AnalysisUkrainianPlugin());
    Analyzer analyzer = analysis.indexAnalyzers.get("ukrainian").analyzer();
    MatcherAssert.assertThat(analyzer, instanceOf(UkrainianMorfologikAnalyzer.class));
}
Also used : UkrainianMorfologikAnalyzer(org.apache.lucene.analysis.uk.UkrainianMorfologikAnalyzer) Index(org.elasticsearch.index.Index) Analyzer(org.apache.lucene.analysis.Analyzer) UkrainianMorfologikAnalyzer(org.apache.lucene.analysis.uk.UkrainianMorfologikAnalyzer) AnalysisUkrainianPlugin(org.elasticsearch.plugin.analysis.ukrainian.AnalysisUkrainianPlugin)

Aggregations

Analyzer (org.apache.lucene.analysis.Analyzer)2 Index (org.elasticsearch.index.Index)2 AnalysisUkrainianPlugin (org.elasticsearch.plugin.analysis.ukrainian.AnalysisUkrainianPlugin)2 TokenStream (org.apache.lucene.analysis.TokenStream)1 CharTermAttribute (org.apache.lucene.analysis.tokenattributes.CharTermAttribute)1 UkrainianMorfologikAnalyzer (org.apache.lucene.analysis.uk.UkrainianMorfologikAnalyzer)1