Should we have a NFA Query? [LUCENE-10010]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
Today when a `RegexpQuery` is created, it will be translated to NFA, determinized to DFA and eventually become an `AutomatonQuery`, which is very fast. However, not every NFA could be determinized to DFA easily, the example given in #11020 showed how easy could a short regexp break the determinize process.
Maybe, instead of marking those kind of queries as adversarial cases, we could make a new kind of NFA query, which execute directly on NFA and thus no need to worry about determinize process or determinized DFA size. It should be slower, but also makes those adversarial cases doable.
[This article](https://swtch.com/\~rsc/regexp/regexp1.html) has provided a simple but efficient way of searching over NFA, essentially it is a partial determinize process that only determinize the necessary part of DFA. Maybe we could give it a try?
---
Migrated from [LUCENE-10010](https://issues.apache.org/jira/browse/LUCENE-10010) by Patrick Zhai (@zhaih), updated Dec 21 2021
Pull requests: https://github.com/apache/lucene/pull/225, https://github.com/apache/lucene/pull/296
Contributor guide
Research direction
Start by reading the RegexpQuery and AutomatonQuery flow described in the issue, then review issue #11020 and the referenced PRs for prior decisions. Compare the proposed partial NFA execution approach with determinization, and treat the work as complete only when adversarial regular expressions can be handled without an impractical determinized DFA.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- search
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100