Skip to content

Remove enum casing override #184

@dbwiddis

Description

@dbwiddis

A bug in Opensearch Java Client v2.x caused an issue with the enum ZeroTermsQuery

It was fixed in OpenSearch Java Client v3, just merged.

We should remove the override:

/**
* If an internal variable is an enum represented by all upper case, the Remote client may have it mapped in lower case. This method lowercases these enum values
* @param field The JSON field to lowercase the value
* @param json The full JSON to process
* @return The JSON with the value lowercased
*/
public static String lowerCaseEnumValues(String field, String json) {
if (field == null) {
return json;
}
if (json == null) {
return null;
}
// Use a matcher to find and replace the field value in lowercase
Matcher matcher = Pattern.compile("(\"" + Pattern.quote(field) + "\"):(\"[A-Z_]+\")").matcher(json);
StringBuffer sb = new StringBuffer();
while (matcher.find()) {
matcher.appendReplacement(sb, matcher.group(1) + ":" + matcher.group(2).toLowerCase(Locale.ROOT));
}
matcher.appendTail(sb);
return sb.toString();
}

While technically not semver compatible for 3.0 to 3.1, it is not used outside this repo so should be safe to remove:

Alternately we can leave it in the util and mark it deprecated, and remove the Remote Client usage of it.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions