FilteredQuery.explain does not honor FilterStrategy [LUCENE-5488]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
Some Filter implementations produce DocIdSets without the iterator() implementation, such as o.a.l.facet.range.Range.getFilter(). It is done with the intention to be used in conjunction with FilteredQuery with FilterStrategy set to be QUERY_FIRST_FILTER_STRATEGY for performance reasons.
However, this behavior is not honored by FilteredQuery.explain where docidset.iterator is called regardless and causing such valid usages of above filter types to fail.
The fix is to check bits() first and and fall back to iterator if bits is null. In which case, the input Filter is indeed bad.
See attached unit test, which fails without this patch.
---
Migrated from [LUCENE-5488](https://issues.apache.org/jira/browse/LUCENE-5488) by John Wang, 1 vote, updated Mar 09 2014
Attachments: [LUCENE-5488.patch](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-5488/LUCENE-5488.patch) (versions: 3)
Contributor guide
Research direction
Start at FilteredQuery.explain and inspect how it uses the DocIdSet from the input Filter, then review Range.getFilter() as an example of a filter without an iterator() implementation. Use the attached unit test to verify that valid QUERY_FIRST_FILTER_STRATEGY usage succeeds and that the fallback behavior is covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- search
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100