Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-749

ChainedFilter does not work well in the event of filters in ANDNOT

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      software platform

    • Lucene Fields:
      Patch Available

      Description

      First ANDNOT operation takes place against a completely false bitset and will always return zero results.

      1. ChainedFilter.patch.txt
        2 kB
        Antonio Bruno
      2. lucene-749.patch
        3 kB
        Doron Cohen

        Activity

        Hide
        elflaco Antonio Bruno added a comment -

        It would have in this way to be:

        ...

        • if (logic == AND)
          + if (logic == AND || logic == ANDNOT) { result = (BitSet) chain[i].bits(reader).clone(); ++i; }

          else

          { result = new BitSet(reader.maxDoc()); }

        for (; i < chain.length; i++)

        { doChain(result, reader, logic, chain[i]); }

        return result;
        ...

        Show
        elflaco Antonio Bruno added a comment - It would have in this way to be: ... if (logic == AND) + if (logic == AND || logic == ANDNOT) { result = (BitSet) chain[i].bits(reader).clone(); ++i; } else { result = new BitSet(reader.maxDoc()); } for (; i < chain.length; i++) { doChain(result, reader, logic, chain[i]); } return result; ...
        Hide
        yseeley@gmail.com Yonik Seeley added a comment -

        Thanks Antonio,
        Could you attach a patch (and click "Grant license to ASF for inclusion in ASF works")
        If you can, a test case for this would be great too!

        Show
        yseeley@gmail.com Yonik Seeley added a comment - Thanks Antonio, Could you attach a patch (and click "Grant license to ASF for inclusion in ASF works") If you can, a test case for this would be great too!
        Hide
        elflaco Antonio Bruno added a comment -

        I correct myself. Task that would have in this way to be:

        if (logic == AND)

        { result = (BitSet) chain[i].bits(reader).clone(); ++i; }

        + else
        + if (logic == ANDNOT)
        +

        { + result = (BitSet) chain[i].bits(reader).clone(); + result.flip(0,reader.maxDoc()); + ++i; + }

        else

        { result = new BitSet(reader.maxDoc()); }

        for (; i < chain.length; i++)

        { doChain(result, reader, logic, chain[i]); }

        return result;

        Show
        elflaco Antonio Bruno added a comment - I correct myself. Task that would have in this way to be: if (logic == AND) { result = (BitSet) chain[i].bits(reader).clone(); ++i; } + else + if (logic == ANDNOT) + { + result = (BitSet) chain[i].bits(reader).clone(); + result.flip(0,reader.maxDoc()); + ++i; + } else { result = new BitSet(reader.maxDoc()); } for (; i < chain.length; i++) { doChain(result, reader, logic, chain[i]); } return result;
        Hide
        elflaco Antonio Bruno added a comment -

        In this way it is avoided that the first ANDNOT operation takes place against a completely false bitset and will always return zero results.

        Show
        elflaco Antonio Bruno added a comment - In this way it is avoided that the first ANDNOT operation takes place against a completely false bitset and will always return zero results.
        Hide
        doronc Doron Cohen added a comment -

        This is a valid issue, and the proposed fix is correct.
        An updated patch with two test cases demonstrating the bug.

        Show
        doronc Doron Cohen added a comment - This is a valid issue, and the proposed fix is correct. An updated patch with two test cases demonstrating the bug.
        Hide
        doronc Doron Cohen added a comment -

        Committed, Thanks Antonio!

        Show
        doronc Doron Cohen added a comment - Committed, Thanks Antonio!

          People

          • Assignee:
            doronc Doron Cohen
            Reporter:
            elflaco Antonio Bruno
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development