Index: ./src/java/org/apache/lucene/analysis/StopFilter.java =================================================================== RCS file: /home/cvspublic/jakarta-lucene/src/java/org/apache/lucene/analysis/StopFilter.java,v retrieving revision 1.3 diff -u -r1.3 StopFilter.java --- ./src/java/org/apache/lucene/analysis/StopFilter.java 9 Dec 2002 19:02:20 -0000 1.3 +++ ./src/java/org/apache/lucene/analysis/StopFilter.java 10 Oct 2003 15:22:43 -0000 @@ -62,6 +62,7 @@ public final class StopFilter extends TokenFilter { private Hashtable table; + private int positionIncrement = 1; /** Constructs a filter which removes words from the input TokenStream that are named in the array of words. */ @@ -90,9 +91,15 @@ /** Returns the next input Token whose termText() is not a stop word. */ public final Token next() throws IOException { // return the first non-stop word found - for (Token token = input.next(); token != null; token = input.next()) - if (table.get(token.termText) == null) + for (Token token = input.next(); token != null; token = input.next()) { + if (table.get(token.termText) == null) { + token.setPositionIncrement(positionIncrement); + positionIncrement = 1; // reset the position increment return token; + } else { + ++positionIncrement; // stopword -- increase the position increment. + } + } // reached EOS -- return null return null; }