Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search - add case insensitive support for regex queries. #59441

Merged
merged 9 commits into from
Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/reference/query-dsl/regexp-query.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ GET /_search
"user.id": {
"value": "k.*y",
"flags": "ALL",
"case_insensitive": true,
"max_determinized_states": 10000,
"rewrite": "constant_score"
}
Expand Down Expand Up @@ -67,6 +68,10 @@ provided. To improve performance, avoid using wildcard patterns, such as `.*` or
valid values and more information, see <<regexp-optional-operators, Regular
expression syntax>>.

`case_insensitive`::
(Optional, boolean) allows case insensitive matching of the regular expression
value with the indexed field values when set to true. Setting to false is disallowed.

`max_determinized_states`::
+
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public Query wildcardQuery(String value,
}

@Override
public Query regexpQuery(String value, int flags, int maxDeterminizedStates,
public Query regexpQuery(String value, int syntaxFlags, int matchFlags, int maxDeterminizedStates,
MultiTermQuery.RewriteMethod method, QueryShardContext context) {
throw new UnsupportedOperationException("[regexp] queries are not supported on [" + CONTENT_TYPE + "] fields.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void testTermsQuery() {
public void testRegexpQuery() {
MappedFieldType ft = new CollationFieldType("field", DEFAULT_COLLATOR);
UnsupportedOperationException e = expectThrows(UnsupportedOperationException.class,
() -> ft.regexpQuery("foo.*", 0, 10, null, randomMockShardContext()));
() -> ft.regexpQuery("foo.*", 0, 0, 10, null, randomMockShardContext()));
assertEquals("[regexp] queries are not supported on [icu_collation_keyword] fields.", e.getMessage());
}

Expand Down
3 changes: 3 additions & 0 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,7 @@ tasks.named("dependencyLicenses").configure {
tasks.named("licenseHeaders").configure {
// Ignore our vendored version of Google Guice
excludes << 'org/elasticsearch/common/inject/**/*'
// Ignore temporary copies of impending 8.7 Lucene classes
excludes << 'org/apache/lucene/search/RegExp87*'
excludes << 'org/apache/lucene/search/RegexpQuery87*'
}
Loading