Skip to content

Commit

Permalink
LUCENE-9386 add case insensitive RegExp matching option (#1541)
Browse files Browse the repository at this point in the history
Added case insensitive search option (currently only works with ASCII characters)
  • Loading branch information
markharwood authored Jul 8, 2020
1 parent 00203c2 commit 887fe4c
Show file tree
Hide file tree
Showing 4 changed files with 224 additions and 82 deletions.
38 changes: 34 additions & 4 deletions lucene/core/src/java/org/apache/lucene/search/RegexpQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public RegexpQuery(Term term, int flags) {
* Constructs a query for terms matching <code>term</code>.
*
* @param term regular expression.
* @param flags optional RegExp features from {@link RegExp}
* @param flags optional RegExp syntax features from {@link RegExp}
* @param maxDeterminizedStates maximum number of states that compiling the
* automaton for the regexp can result in. Set higher to allow more complex
* queries and lower to prevent memory exhaustion.
Expand All @@ -96,16 +96,46 @@ public RegexpQuery(Term term, int flags, int maxDeterminizedStates) {
* Constructs a query for terms matching <code>term</code>.
*
* @param term regular expression.
* @param flags optional RegExp features from {@link RegExp}
* @param syntax_flags optional RegExp syntax features from {@link RegExp}
* automaton for the regexp can result in. Set higher to allow more complex
* queries and lower to prevent memory exhaustion.
* @param match_flags boolean 'or' of match behavior options such as case insensitivity
* @param maxDeterminizedStates maximum number of states that compiling the
*/
public RegexpQuery(Term term, int syntax_flags, int match_flags, int maxDeterminizedStates) {
this(term, syntax_flags, match_flags, defaultProvider, maxDeterminizedStates);
}

/**
* Constructs a query for terms matching <code>term</code>.
*
* @param term regular expression.
* @param syntax_flags optional RegExp features from {@link RegExp}
* @param provider custom AutomatonProvider for named automata
* @param maxDeterminizedStates maximum number of states that compiling the
* automaton for the regexp can result in. Set higher to allow more complex
* queries and lower to prevent memory exhaustion.
*/
public RegexpQuery(Term term, int syntax_flags, AutomatonProvider provider,
int maxDeterminizedStates) {
this(term, syntax_flags, 0, provider, maxDeterminizedStates);
}

/**
* Constructs a query for terms matching <code>term</code>.
*
* @param term regular expression.
* @param syntax_flags optional RegExp features from {@link RegExp}
* @param match_flags boolean 'or' of match behavior options such as case insensitivity
* @param provider custom AutomatonProvider for named automata
* @param maxDeterminizedStates maximum number of states that compiling the
* automaton for the regexp can result in. Set higher to allow more complex
* queries and lower to prevent memory exhaustion.
*/
public RegexpQuery(Term term, int flags, AutomatonProvider provider,
public RegexpQuery(Term term, int syntax_flags, int match_flags, AutomatonProvider provider,
int maxDeterminizedStates) {
super(term,
new RegExp(term.text(), flags).toAutomaton(
new RegExp(term.text(), syntax_flags, match_flags).toAutomaton(
provider, maxDeterminizedStates), maxDeterminizedStates);
}

Expand Down
Loading

0 comments on commit 887fe4c

Please sign in to comment.