apache / apache/lucene

TermQuery can rewrite to MatchAll/No DocsQuery

Open
#15,845 1 comment 0 reactions 0 assignees View on GitHub
type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

### Description

In case a `Term` is indexed for every document (in a segment) we could rewrite `TermQuery` for that to `MatchAllDocsQuery` easily by looking at term statistics. Are we trying to avoid looking up terms during rewrite or something?

Contributor guide

Open the contributing guide

Research direction

Start by reading the TermQuery rewrite path and the term-statistics APIs it can access. Determine whether segment-level document-frequency statistics can identify terms present in every document or absent from all documents, and define tests that verify any MatchAllDocsQuery or NoDocsQuery rewrite without changing other query behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.