Skip to content

Commit 887fe4c

Browse files
authored
LUCENE-9386 add case insensitive RegExp matching option (#1541)
Added case insensitive search option (currently only works with ASCII characters)
1 parent 00203c2 commit 887fe4c

File tree

4 files changed

+224
-82
lines changed

4 files changed

+224
-82
lines changed

lucene/core/src/java/org/apache/lucene/search/RegexpQuery.java

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public RegexpQuery(Term term, int flags) {
8383
* Constructs a query for terms matching <code>term</code>.
8484
*
8585
* @param term regular expression.
86-
* @param flags optional RegExp features from {@link RegExp}
86+
* @param flags optional RegExp syntax features from {@link RegExp}
8787
* @param maxDeterminizedStates maximum number of states that compiling the
8888
* automaton for the regexp can result in. Set higher to allow more complex
8989
* queries and lower to prevent memory exhaustion.
@@ -96,16 +96,46 @@ public RegexpQuery(Term term, int flags, int maxDeterminizedStates) {
9696
* Constructs a query for terms matching <code>term</code>.
9797
*
9898
* @param term regular expression.
99-
* @param flags optional RegExp features from {@link RegExp}
99+
* @param syntax_flags optional RegExp syntax features from {@link RegExp}
100+
* automaton for the regexp can result in. Set higher to allow more complex
101+
* queries and lower to prevent memory exhaustion.
102+
* @param match_flags boolean 'or' of match behavior options such as case insensitivity
103+
* @param maxDeterminizedStates maximum number of states that compiling the
104+
*/
105+
public RegexpQuery(Term term, int syntax_flags, int match_flags, int maxDeterminizedStates) {
106+
this(term, syntax_flags, match_flags, defaultProvider, maxDeterminizedStates);
107+
}
108+
109+
/**
110+
* Constructs a query for terms matching <code>term</code>.
111+
*
112+
* @param term regular expression.
113+
* @param syntax_flags optional RegExp features from {@link RegExp}
114+
* @param provider custom AutomatonProvider for named automata
115+
* @param maxDeterminizedStates maximum number of states that compiling the
116+
* automaton for the regexp can result in. Set higher to allow more complex
117+
* queries and lower to prevent memory exhaustion.
118+
*/
119+
public RegexpQuery(Term term, int syntax_flags, AutomatonProvider provider,
120+
int maxDeterminizedStates) {
121+
this(term, syntax_flags, 0, provider, maxDeterminizedStates);
122+
}
123+
124+
/**
125+
* Constructs a query for terms matching <code>term</code>.
126+
*
127+
* @param term regular expression.
128+
* @param syntax_flags optional RegExp features from {@link RegExp}
129+
* @param match_flags boolean 'or' of match behavior options such as case insensitivity
100130
* @param provider custom AutomatonProvider for named automata
101131
* @param maxDeterminizedStates maximum number of states that compiling the
102132
* automaton for the regexp can result in. Set higher to allow more complex
103133
* queries and lower to prevent memory exhaustion.
104134
*/
105-
public RegexpQuery(Term term, int flags, AutomatonProvider provider,
135+
public RegexpQuery(Term term, int syntax_flags, int match_flags, AutomatonProvider provider,
106136
int maxDeterminizedStates) {
107137
super(term,
108-
new RegExp(term.text(), flags).toAutomaton(
138+
new RegExp(term.text(), syntax_flags, match_flags).toAutomaton(
109139
provider, maxDeterminizedStates), maxDeterminizedStates);
110140
}
111141

0 commit comments

Comments
 (0)