Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop Token Filter - allow to set enable_position_increments #1182

Closed
gustavobmaia opened this issue Jul 29, 2011 · 1 comment
Closed

Stop Token Filter - allow to set enable_position_increments #1182

gustavobmaia opened this issue Jul 29, 2011 · 1 comment

Comments

@gustavobmaia
Copy link

hello,
I was having problem with the filter StopFilter using enable_position_increments token = false; When I did a search the result was not even setting enable_position_increments = false in the query.

Began to look at the code of the elastic i saw some problem with enable_position_increments in object StopFilter on the class StopTokenFilterFactory. So I changed it by adding the following line:

public class StopTokenFilterFactory extends AbstractTokenFilterFactory {

private final Set<?> stopWords;

private final boolean ignoreCase;

NEW LINE **** 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);
  NEW LINE ****  this.enablePositionIncrements = settings.getAsBoolean("enable_position_increments", true);
}

@Override public TokenStream create(TokenStream tokenStream) {
NEW LINE ****   StopFilter stopFilter = new StopFilter(version, tokenStream, stopWords, ignoreCase);
NEW LINE ****   stopFilter.setEnablePositionIncrements(enablePositionIncrements);
    return stopFilter;
}

public Set<?> stopWords() {
    return stopWords;
}

public boolean ignoreCase() {
    return ignoreCase;
}

}

@kimchy
Copy link
Member

kimchy commented Jul 29, 2011

Thanks, will add this option to 0.17 and master branch.

@kimchy kimchy closed this as completed in 7271a80 Jul 29, 2011
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
jev001 pushed a commit to jev001/elasticsearch that referenced this issue Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants