apache / apache/lucene

RegExp with group references [LUCENE-9696]

Open
#10,735 1 comment 0 reactions 0 assignees View on GitHub
legacy-jira-priority:Minor type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

PatternTypingFilter presently relies on java util regexes, but #8517 found performance benefits using our own RegExp class instead. Unfortunately RegExp does not currently report matching subgroups which is key to PatternTypingFilter's use (and probably useful in other endeavors as well).  What's needed is reporting of sub-groups such that 

new RegExp("(foo(.+)")) -~~>> converted to run atomaton etc -~~> match found for "foobar" --> somehow reports getGroup(1) as "bar"

And getGroup() can be called on some object reasonably accessible to the code using RegExp in the first place.

Clearly there's a lot to be worked out there since the normal usage pattern converts things to a DFA / run Automaton etc, and subgroups are not a natural concept for those classes. But if this could be achieved without loosing the performance benefits, that would be interesting :).

Opening this Wish ticket as encouraged by @mikemccand in #10615.  I won't be able to work on it any time soon to encourage anyone else interested to pick it up or to drop links or ideas in here.

---
Migrated from [LUCENE-9696](https://issues.apache.org/jira/browse/LUCENE-9696) by Gus Heck (@gus-asf), updated Jan 26 2021

Contributor guide

Open the contributing guide

Research direction

Start with PatternTypingFilter and the RegExp class, then review issue #8517 for the existing performance motivation. Investigate how RegExp converts patterns to DFAs or Automata and where match results are exposed. Done means subgroup values such as getGroup(1) can be reported without losing the intended performance benefits.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.