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

[Backport 2.17] [Backport 2.x] fix wildcard term & terms query & add YAML REST test #15706

Merged
merged 1 commit into from
Sep 5, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,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 @@

@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);

Check warning on line 638 in server/src/main/java/org/opensearch/index/mapper/WildcardFieldMapper.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/index/mapper/WildcardFieldMapper.java#L638

Added line #L638 was not covered by tests
}

@Override
Expand All @@ -649,7 +649,7 @@
Set<String> expectedValues = new HashSet<>();
StringBuilder pattern = new StringBuilder();
for (Object value : values) {
String stringVal = value.toString();
String stringVal = BytesRefs.toString(value);

Check warning on line 652 in server/src/main/java/org/opensearch/index/mapper/WildcardFieldMapper.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/index/mapper/WildcardFieldMapper.java#L652

Added line #L652 was not covered by tests
builder.add(matchAllTermsQuery(name(), getRequiredNGrams(stringVal)), BooleanClause.Occur.SHOULD);
expectedValues.add(stringVal);
if (pattern.length() > 0) {
Expand Down
Loading