diff --git a/CHANGES.txt b/CHANGES.txt index 4d5979c9308..c1475ea531a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -213,6 +213,10 @@ Bug fixes inside a BooleanQuery. (Hans Hjelm and Scotty Allen via Daniel Naber, Bug #35626) +11. Fixed SnowballFilter to pass through the position increment from + the original token. + (Yonik Seeley via Erik Hatcher, LUCENE-437) + Optimizations 1. Disk usage (peak requirements during indexing and optimization) diff --git a/contrib/snowball/src/java/org/apache/lucene/analysis/snowball/SnowballFilter.java b/contrib/snowball/src/java/org/apache/lucene/analysis/snowball/SnowballFilter.java index bbb39f9b636..5385719ca09 100644 --- a/contrib/snowball/src/java/org/apache/lucene/analysis/snowball/SnowballFilter.java +++ b/contrib/snowball/src/java/org/apache/lucene/analysis/snowball/SnowballFilter.java @@ -69,7 +69,10 @@ public class SnowballFilter extends TokenFilter { } catch (Exception e) { throw new RuntimeException(e.toString()); } - return new Token(stemmer.getCurrent(), - token.startOffset(), token.endOffset(), token.type()); + + Token newToken = new Token(stemmer.getCurrent(), + token.startOffset(), token.endOffset(), token.type()); + newToken.setPositionIncrement(token.getPositionIncrement()); + return newToken; } } diff --git a/contrib/snowball/src/test/org/apache/lucene/analysis/snowball/TestSnowball.java b/contrib/snowball/src/test/org/apache/lucene/analysis/snowball/TestSnowball.java index 581b7898529..f7d9681ce20 100644 --- a/contrib/snowball/src/test/org/apache/lucene/analysis/snowball/TestSnowball.java +++ b/contrib/snowball/src/test/org/apache/lucene/analysis/snowball/TestSnowball.java @@ -55,6 +55,7 @@ package org.apache.lucene.analysis.snowball; */ import java.io.*; + import junit.framework.*; import org.apache.lucene.analysis.*; @@ -65,7 +66,7 @@ public class TestSnowball extends TestCase { String input, String[] output) throws Exception { TokenStream ts = a.tokenStream("dummy", new StringReader(input)); - for (int i=0; i