apache / apache/lucene

PointInSetQuery does not terminate early if result iterator has no docs [LUCENE-9584]

Open
#10,624 1 comment 0 reactions 0 assignees View on GitHub
affects-version:7.7.3 affects-version:8.6.3 legacy-jira-label:performance legacy-jira-priority:Major module:core/search type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

Today, in a point in set query after BKD intersect we get a DocIdSetBuilder result, if result's iterator have no docs, then the PointInSetQuery still create ConstantScoreScorer with an empty DocIdSetIterator. 

In a Boolean Query, such as query = subQuery1 AND subQuery2 AND subQuery3 .... subQueryN

if subQuery1 is a PointInSetQuery and get an empty result iterator, and subsequent subQuery2 \~ subQueryN would still evaluate to call build scorer, this is an unnecessary cost for this query if subQuery1 have already got an empty result iterator .

---
Migrated from [LUCENE-9584](https://issues.apache.org/jira/browse/LUCENE-9584) by hackerwin7 (@hackerwin7), updated Nov 18 2020
Attachments: [LUCENE-7.7.0-PointInSetQuery_terminate_early.patch](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-9584/LUCENE-7.7.0-PointInSetQuery_terminate_early.patch)

Contributor guide

Open the contributing guide

Research direction

Start with PointInSetQuery and trace the BKD intersect result through DocIdSetBuilder and ConstantScoreScorer. Verify the empty-iterator case and check that a Boolean query no longer builds subsequent scorers unnecessarily; the attached LUCENE-7.7.0-PointInSetQuery_terminate_early.patch is available for context.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.