[ 
https://issues.apache.org/jira/browse/LUCENE-3609?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13159512#comment-13159512
 ] 

Shay Banon commented on LUCENE-3609:
------------------------------------

What I am saying is that BooleanFilter used to act in a way that at least one 
should clause should match, and it is no longer the case. Here is the logic 
that was before:

{code}
if (shouldFilters != null) {
      for (int i = 0; i < shouldFilters.size(); i++) {
        if (res == null) {
          res = new OpenBitSetDISI(getDISI(shouldFilters, i, reader), 
reader.maxDoc());
        } else { 
          DocIdSet dis = shouldFilters.get(i).getDocIdSet(reader);
          if(dis instanceof OpenBitSet) {
            // optimized case for OpenBitSets
            res.or((OpenBitSet) dis);
          } else {
            res.inPlaceOr(getDISI(shouldFilters, i, reader));
          }
        }
      }
    }
{code}
    
Assuming the getDISI returns EMTY iterator for a filter that does not match 
(and not null, as it will fail) for a single should clause, then the result of 
this will be a "res" all "zeroed" out (the first check on res==null). Then, if 
it went ahead and executed a must clause, it would and on a "zeroed" out bitset 
and the result is no matches.

Now, with the change, we have this code:

{code}
for (final FilterClause fc : clauses) {
  if (fc.getOccur() == Occur.SHOULD) {
    final DocIdSetIterator disi = getDISI(fc.getFilter(), reader);
    if (disi == null) continue;
    if (res == null) {
      res = new FixedBitSet(reader.maxDoc());
    }
    res.or(disi);
  }
}
{code}

The result of a single should clause that does not match anything is a res 
still set to null, and then, when it gets to the must clause, it will or it 
with the result of the must clause, and return the docs that match the must 
clause. You can see this is different compared to the previous behavior and 
actually, different than the expected behavior.
                
> BooleanFilter changed behavior in 3.5, no longer acts as if "minimum should 
> match" set to 1
> -------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3609
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3609
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: core/search
>    Affects Versions: 3.5
>            Reporter: Shay Banon
>            Assignee: Uwe Schindler
>
> The change LUCENE-3446 causes a change in behavior in BooleanFilter. It used 
> to work as if minimum should match clauses is 1 (compared to BQ lingo), but 
> now, if no should clauses match, then the should clauses are ignored, and for 
> example, if there is a must clause, only that one will be used and returned.
> For example, a single must clause and should clause, with the should clause 
> not matching anything, should not match anything, but, it will match whatever 
> the must clause matches.
> The fix is simple, after iterating over the should clauses, if the aggregated 
> bitset is null, return null.

--
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]

Reply via email to