Can we simplify conjunctions of range queries automatically? [LUCENE-8708]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
BooleanQuery#rewrite already has some logic to make queries more efficient, such as deduplicating filters or rewriting boolean queries that wrap a single positive clause to that clause.
It would be nice to also simplify conjunctions of range queries, so that eg. `foo: [5 TO *] AND foo:[* TO 20]` would be rewritten to `foo:[5 TO 20]`. When constructing queries manually or via the classic query parser, it feels unnecessary as this is something that the user can fix easily. However if you want to implement a query parser that only allows specifying one bound at once, such as Gmail (`after:2018-12-31` https://support.google.com/mail/answer/7190?hl=en) or GitHub (`updated:>=2018-12-31` https://help.github.com/en/articles/searching-issues-and-pull-requests#search-by-when-an-issue-or-pull-request-was-created-or-last-updated) then you might end up with inefficient queries if the end user specifies both an upper and a lower bound. It would be nice if we optimized those automatically.
---
Migrated from [LUCENE-8708](https://issues.apache.org/jira/browse/LUCENE-8708) by Adrien Grand (@jpountz), updated May 01 2019
Attachments: [interval_range_clauses_merging0704.patch](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-8708/interval_range_clauses_merging0704.patch)
Contributor guide
Research direction
Start at BooleanQuery#rewrite and inspect its existing deduplication and single-positive-clause rewrites, then review the attached interval_range_clauses_merging0704.patch for prior context. Done means conjunctions of range queries on the same field are merged into one range query while preserving the correct bounds and 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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100