apache / apache/lucene

Regex Query with Backreferences [LUCENE-7411]

Open
#8,464 10 comments 0 reactions 0 assignees View on GitHub
legacy-jira-priority:Minor module:core/search type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

Hi there,

I am currently working on a Regex Engine that supports Backreferences while not losing determinism. It uses Memory Occurence Automata (MOAs) in the engine which are more powerful than normal DFA/NFAs. The engine does no backtracking and recognizes Regexes that cannot be evaluated deterministically as malformed. It has become more and more mature in the last few weeks and I also implemented a Lucene Query that uses these Patterns in the background. Now my question is: Is there any interest for this work to be merged (or adapted) into Lucene core?

EDIT:

The current state is only a mere proof of concept. The performance can probably be improved by a lot by adapting concepts of the Lucene Regexp Query. As Uwe Schindler correctly stated, the Query currently is quite "dumb" as in it doesn't predict what terms to match next.

https://github.com/s4ke/moar

Usage example for the Lucene Query:

https://github.com/s4ke/moar/blob/master/lucene/src/test/java/com/github/s4ke/moar/lucene/query/test/MoarQueryTest.java#L126

Cheers,

Martin

---
Migrated from [LUCENE-7411](https://issues.apache.org/jira/browse/LUCENE-7411) by Martin Braun, updated Aug 23 2016

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the proof-of-concept at https://github.com/s4ke/moar and its example test, lucene/src/test/java/com/github/s4ke/moar/lucene/query/test/MoarQueryTest.java, then compare its approach with Lucene's Regexp Query. Done requires a concrete proposal and an agreed path for adapting or merging deterministic backreference query support into Lucene core.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.