Stop Token Filter - enable_position_increments, closes #1182.
This commit is contained in:
parent
a09ed1468c
commit
7271a80b50
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.analysis;
|
|||
import org.apache.lucene.analysis.StopAnalyzer;
|
||||
import org.apache.lucene.analysis.StopFilter;
|
||||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.util.Version;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.inject.assistedinject.Assisted;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -40,14 +41,19 @@ public class StopTokenFilterFactory extends AbstractTokenFilterFactory {
|
|||
|
||||
private final boolean ignoreCase;
|
||||
|
||||
private final boolean enablePositionIncrements;
|
||||
|
||||
@Inject public StopTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) {
|
||||
super(index, indexSettings, name, settings);
|
||||
this.stopWords = Analysis.parseStopWords(env, settings, StopAnalyzer.ENGLISH_STOP_WORDS_SET);
|
||||
this.ignoreCase = settings.getAsBoolean("ignore_case", false);
|
||||
this.enablePositionIncrements = settings.getAsBoolean("enable_position_increments", version.onOrAfter(Version.LUCENE_29));
|
||||
}
|
||||
|
||||
@Override public TokenStream create(TokenStream tokenStream) {
|
||||
return new StopFilter(version, tokenStream, stopWords, ignoreCase);
|
||||
StopFilter filter = new StopFilter(version, tokenStream, stopWords, ignoreCase);
|
||||
filter.setEnablePositionIncrements(enablePositionIncrements);
|
||||
return filter;
|
||||
}
|
||||
|
||||
public Set<?> stopWords() {
|
||||
|
@ -57,4 +63,8 @@ public class StopTokenFilterFactory extends AbstractTokenFilterFactory {
|
|||
public boolean ignoreCase() {
|
||||
return ignoreCase;
|
||||
}
|
||||
|
||||
public boolean enablePositionIncrements() {
|
||||
return this.enablePositionIncrements;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue