[ 
https://issues.apache.org/jira/browse/JCR-3539?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ard Schrijvers resolved JCR-3539.
---------------------------------

    Resolution: Fixed
    
> NotQuery#advance (and for older versions skipTo) violates Lucene advance 
> contract in case a Filter is used
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: JCR-3539
>                 URL: https://issues.apache.org/jira/browse/JCR-3539
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core
>            Reporter: Ard Schrijvers
>            Assignee: Ard Schrijvers
>             Fix For: 2.2.14, 2.4.4, 2.6.1, 2.7
>
>
> 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()); )

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to