Skip to content

Commit

Permalink
Advance search - Added case sensitive flag for wildcard searches (dat…
Browse files Browse the repository at this point in the history
…ahub-project#11272)

Co-authored-by: mac <mac@192.168.1.7>
Co-authored-by: david-leifker <114954101+david-leifker@users.noreply.github.com>
Co-authored-by: Kanav Narula <kanav_narula@optum.com>
  • Loading branch information
4 people authored Sep 18, 2024
1 parent 8ea2117 commit 4693ab0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,8 @@ private static QueryBuilder buildWildcardQueryWithMultipleValues(
QueryBuilders.wildcardQuery(
toKeywordField(criterion.getField(), isTimeseries, aspectRetriever),
String.format(wildcardPattern, ESUtils.escapeReservedCharacters(value.trim())))
.queryName(queryName != null ? queryName : fieldName));
.queryName(queryName != null ? queryName : fieldName)
.caseInsensitive(true));
}
return boolQuery;
}
Expand All @@ -653,7 +654,8 @@ private static QueryBuilder buildWildcardQueryWithSingleValue(
toKeywordField(criterion.getField(), isTimeseries, aspectRetriever),
String.format(
wildcardPattern, ESUtils.escapeReservedCharacters(criterion.getValue().trim())))
.queryName(queryName != null ? queryName : fieldName);
.queryName(queryName != null ? queryName : fieldName)
.caseInsensitive(true);
}

private static QueryBuilder buildContainsConditionFromCriterion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public void testGetQueryBuilderFromCriterionContain() {
+ " \"wildcard\" : {\n"
+ " \"myTestField.keyword\" : {\n"
+ " \"wildcard\" : \"*value1*\",\n"
+ " \"case_insensitive\" : true,\n"
+ " \"boost\" : 1.0,\n"
+ " \"_name\" : \"myTestField\"\n"
+ " }\n"
Expand Down Expand Up @@ -207,6 +208,7 @@ public void testGetQueryBuilderFromCriterionContain() {
+ " \"wildcard\" : {\n"
+ " \"myTestField.keyword\" : {\n"
+ " \"wildcard\" : \"*value1*\",\n"
+ " \"case_insensitive\" : true,\n"
+ " \"boost\" : 1.0,\n"
+ " \"_name\" : \"myTestField\"\n"
+ " }\n"
Expand All @@ -216,6 +218,7 @@ public void testGetQueryBuilderFromCriterionContain() {
+ " \"wildcard\" : {\n"
+ " \"myTestField.keyword\" : {\n"
+ " \"wildcard\" : \"*value2*\",\n"
+ " \"case_insensitive\" : true,\n"
+ " \"boost\" : 1.0,\n"
+ " \"_name\" : \"myTestField\"\n"
+ " }\n"
Expand Down Expand Up @@ -251,6 +254,7 @@ public void testWildcardQueryBuilderFromCriterionWhenStartsWith() {
+ " \"wildcard\" : {\n"
+ " \"myTestField.keyword\" : {\n"
+ " \"wildcard\" : \"value1*\",\n"
+ " \"case_insensitive\" : true,\n"
+ " \"boost\" : 1.0,\n"
+ " \"_name\" : \"myTestField\"\n"
+ " }\n"
Expand Down Expand Up @@ -281,6 +285,7 @@ public void testWildcardQueryBuilderFromCriterionWhenStartsWith() {
+ " \"wildcard\" : {\n"
+ " \"myTestField.keyword\" : {\n"
+ " \"wildcard\" : \"value1*\",\n"
+ " \"case_insensitive\" : true,\n"
+ " \"boost\" : 1.0,\n"
+ " \"_name\" : \"myTestField\"\n"
+ " }\n"
Expand All @@ -290,6 +295,7 @@ public void testWildcardQueryBuilderFromCriterionWhenStartsWith() {
+ " \"wildcard\" : {\n"
+ " \"myTestField.keyword\" : {\n"
+ " \"wildcard\" : \"value2*\",\n"
+ " \"case_insensitive\" : true,\n"
+ " \"boost\" : 1.0,\n"
+ " \"_name\" : \"myTestField\"\n"
+ " }\n"
Expand Down Expand Up @@ -322,6 +328,7 @@ public void testWildcardQueryBuilderFromCriterionWhenEndsWith() {
+ " \"wildcard\" : {\n"
+ " \"myTestField.keyword\" : {\n"
+ " \"wildcard\" : \"*value1\",\n"
+ " \"case_insensitive\" : true,\n"
+ " \"boost\" : 1.0,\n"
+ " \"_name\" : \"myTestField\"\n"
+ " }\n"
Expand Down Expand Up @@ -351,6 +358,7 @@ public void testWildcardQueryBuilderFromCriterionWhenEndsWith() {
+ " \"wildcard\" : {\n"
+ " \"myTestField.keyword\" : {\n"
+ " \"wildcard\" : \"*value1\",\n"
+ " \"case_insensitive\" : true,\n"
+ " \"boost\" : 1.0,\n"
+ " \"_name\" : \"myTestField\"\n"
+ " }\n"
Expand All @@ -360,6 +368,7 @@ public void testWildcardQueryBuilderFromCriterionWhenEndsWith() {
+ " \"wildcard\" : {\n"
+ " \"myTestField.keyword\" : {\n"
+ " \"wildcard\" : \"*value2\",\n"
+ " \"case_insensitive\" : true,\n"
+ " \"boost\" : 1.0,\n"
+ " \"_name\" : \"myTestField\"\n"
+ " }\n"
Expand Down

0 comments on commit 4693ab0

Please sign in to comment.