[
https://issues.apache.org/jira/browse/LUCENE-3849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13438244#comment-13438244
]
Robert Muir commented on LUCENE-3849:
-------------------------------------
{quote}
where does the "positionIncrementGap" come in? because my naive impression is
that the end() method is precisely where something like
posIncAtt.setPositionIncrement(getPositionIncrementaGap()) should be called.
{quote}
PositionIncrementGap is not related to this bug, because its something done
separately by indexwriter. Its always factored in correctly, its not buggy.
The "bug" is if a field instance ends with a stopword, that accumulated 'hole'
is lost.
{noformat}
doc.add(new TextField("body", "just a", Field.Store.NO));
doc.add(new TextField("body", "test of gaps", Field.Store.NO));
iw.addDocument(doc);
...
PhraseQuery pq = new PhraseQuery();
pq.add(new Term("body", "just"), 0);
pq.add(new Term("body", "test"), 2);
// body:"just ? test"
assertEquals(1, is.search(pq, 5).totalHits); // FAIL!
{noformat}
So the problem is the first instance of the field loses its hole for "a" (a
stopword that was removed),
only because it ended on a stopword, so incrementToken() returned false and
there was no subsequent token
to apply the 'hole' to.
This is the same problem as an instance of a field ending with say a space
character and all the offsets being wrong,
this was why end() was added, so the indexer can pull 'end of stream state'.
> position increments should be implemented by TokenStream.end()
> --------------------------------------------------------------
>
> Key: LUCENE-3849
> URL: https://issues.apache.org/jira/browse/LUCENE-3849
> Project: Lucene - Core
> Issue Type: Bug
> Affects Versions: 3.6, 4.0-ALPHA
> Reporter: Robert Muir
> Attachments: LUCENE-3849.patch
>
>
> if you have pages of a book as multivalued fields, with the default position
> increment gap
> of analyzer.java (0), phrase queries won't work across pages if one ends with
> stopword(s).
> This is because the 'trailing holes' are not taken into account in end(). So
> I think in
> TokenStream.end(), subclasses of FilteringTokenFilter (e.g. stopfilter)
> should do:
> {code}
> super.end();
> posIncAtt += skippedPositions;
> {code}
> One problem is that these filters need to 'add' to the posinc, but currently
> nothing clears
> the attributes for end() [they are dirty, except offset which is set by the
> tokenizer].
> Also the indexer should be changed to pull posIncAtt from end().
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]