Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Plain jackrabbit does not directly suffer from the issue in the NotQuery, but it surfaces when searching with a org.apache.lucene.search.Filterorg.apache.lucene.search.Filter.
The following happens when calling JackrabbitIndexSearcher#search(Query,Filter,int) (or any other search method containing a filter). In Lucene 3.6.0 (older Lucene version in older jackrabbit versions similar issue) at FilterQuery#getFilterScorer, there is
@Override
public void score(Collector collector) throws IOException {
int filterDoc = filterIter.nextDoc();
int scorerDoc = scorer.advance(filterDoc);
The scorer gets advanced with 'scorer.advance(filterDoc)' : If the scorer contains a Jackrabbit NotQuery, this results in NotQuery#advance being invoked. At this time, NotQuery#nextDoc() has not yet ever been invoked.
The NotQuery#advance results in that docNo becomes some positive number (0 or larger). After this, when NotQuery#nextDoc() gets invoked, the docNo is not -1 any more, and the contextScorer.nextDoc(); is never called any more, ever. Hence, when a FIlter gets applied, the NotQuery is completely skipped.
Fix is simply to replace the
if (docNo == -1) {
with a
if (firstTime) {
firstTime = false;
(in older lucene versions the problem results in false 'more' for IndexSearcher in this line: boolean more = filterDocIdIterator.next() && scorer.skipTo(filterDocIdIterator.doc()); )