@Override public TokenStream create(TokenStream tokenStream) { if (removeTrailing) { return new StopFilter(tokenStream, stopWords); } else { return new SuggestStopFilter(tokenStream, stopWords); } }
public void testThatSuggestStopFilterWorks() throws Exception { Settings settings = Settings.builder() .put("index.analysis.filter.my_stop.type", "stop") .put("index.analysis.filter.my_stop.remove_trailing", false) .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) .build(); ESTestCase.TestAnalysis analysis = AnalysisTestsHelper.createTestAnalysisFromSettings(settings); TokenFilterFactory tokenFilter = analysis.tokenFilter.get("my_stop"); assertThat(tokenFilter, instanceOf(StopTokenFilterFactory.class)); Tokenizer tokenizer = new WhitespaceTokenizer(); tokenizer.setReader(new StringReader("foo an")); TokenStream create = tokenFilter.create(tokenizer); assertThat(create, instanceOf(SuggestStopFilter.class)); }
@Override public TokenStream create(TokenStream tokenStream) { if (removeTrailing) { if (version.onOrAfter(Version.LUCENE_4_4)) { return new StopFilter(tokenStream, stopWords); } else { return new Lucene43StopFilter(enablePositionIncrements, tokenStream, stopWords); } } else { return new SuggestStopFilter(tokenStream, stopWords); } }
@Override public TokenStream create(final TokenStream tokenStream) { if (removeTrailing) { return new StopFilter(tokenStream, stopWords); } else { return new SuggestStopFilter(tokenStream, stopWords); } }