Skip to content

Commit

Permalink
fix wildcard term & terms query & add YAML REST test (#15607) (#15682) (
Browse files Browse the repository at this point in the history
  • Loading branch information
opensearch-trigger-bot[bot] authored Sep 5, 2024
1 parent 0fd6a6a commit ed66587
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fix split response processor not included in allowlist ([#15393](https://github.com/opensearch-project/OpenSearch/pull/15393))
- Fix unchecked cast in dynamic action map getter ([#15394](https://github.com/opensearch-project/OpenSearch/pull/15394))
- Fix null values indexed as "null" strings in flat_object field ([#14069](https://github.com/opensearch-project/OpenSearch/pull/14069))
- Fix terms query on wildcard field returns nothing ([#15607](https://github.com/opensearch-project/OpenSearch/pull/15607))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,13 @@ setup:
my_field:
value: ".*"
- match: { hits.total.value: 5 }
---
"terms query on wildcard field matches":
- do:
search:
index: test
body:
query:
terms: { my_field: ["AbCd"] }
- match: { hits.total.value: 1 }
- match: { hits.hits.0._id: "5" }
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower

@Override
public Query termQueryCaseInsensitive(Object value, QueryShardContext context) {
return wildcardQuery(value.toString(), MultiTermQuery.CONSTANT_SCORE_REWRITE, true, context);
return wildcardQuery(BytesRefs.toString(value), MultiTermQuery.CONSTANT_SCORE_REWRITE, true, context);
}

@Override
Expand All @@ -649,7 +649,7 @@ public Query termsQuery(List<?> values, QueryShardContext context) {
Set<String> expectedValues = new HashSet<>();
StringBuilder pattern = new StringBuilder();
for (Object value : values) {
String stringVal = value.toString();
String stringVal = BytesRefs.toString(value);
builder.add(matchAllTermsQuery(name(), getRequiredNGrams(stringVal)), BooleanClause.Occur.SHOULD);
expectedValues.add(stringVal);
if (pattern.length() > 0) {
Expand Down

0 comments on commit ed66587

Please sign in to comment.