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

John Wang commented on LUCENE-5495:
-----------------------------------

Hi Uwe:

    Looking at the Filter doc, I don't see the stated contract to always check 
iterator before bits. It does say however, bits is not always implemented, and 
if it is, indicates this has random access.

    In the current BooleanFilter implementation, it is essentially converting 
iterators from Filters into a FixedBitSet by iterating. So in the case with 
Filters with a forward index backing, it is scanning the entire index, e.g. 0 
to maxDoc for each filter clause. So this patch checks for bits() and treat 
them differently, if bits() returning null, then checks for iterator, this 
logic does follow the contract as it states, bits is not always implemented, 
but iterator must be. So IMO, even if the facets filter do have iterator() 
implemented, this is still an optimization.

 -John

> Boolean Filter does not handle FilterClauses with only bits() implemented
> -------------------------------------------------------------------------
>
>                 Key: LUCENE-5495
>                 URL: https://issues.apache.org/jira/browse/LUCENE-5495
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: core/search
>    Affects Versions: 4.6.1
>            Reporter: John Wang
>         Attachments: LUCENE-5495.patch, LUCENE-5495.patch
>
>
> Some Filter implementations produce DocIdSets without the iterator() 
> implementation, such as o.a.l.facet.range.Range.getFilter().
> Currently, such filters cannot be added to a BooleanFilter because 
> BooleanFilter expects all FilterClauses with Filters that have iterator() 
> implemented.
> This patch improves the behavior by taking Filters with bits() implemented 
> and treat them separately.
> This behavior would be faster in the case for Filters with a forward index as 
> the underlying data structure, where there would be no need to scan the index 
> to build an iterator.
> See attached unit test, which fails without this patch.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to