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

Uwe Schindler commented on LUCENE-5495:
---------------------------------------

John,
I was about to improve the documentation. The problem is as you explain:
- bits() is mentioning optional
- iterator() does not mention optional, so it is a requirement

And code in FilteredQuery behaves like this:
- Get iterator(), if iterator returns null, no documents match -> exit
- The code then tries to get bits(), if this returns something != 0 and some 
other conditions apply (depending on FilterStrategy) it switches to pass the 
bits() down low (means as liveDocs to the query)
- otherwise it uses the iterator to leap-frog (or similar) with the query.

ConstantScoreQuery always uses the iterator (because it is a query, that needs 
a scorer, which is a subclass of DocIdSetIterator). bits() are never checked.

BooleanFilter works exactly like that. It addtionally also transforms 
iterator-only filters to bits() filters, because it uses a FixedBitSet to cache.

In addition BooleanFilter uses FixedBitSet.or(Iterator), which shortcuts the 
case, where the iterator is derieved from another FixedBitset.


> 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to