Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
Version 2.4.1 of client library
Describe the issue:
I am getting an error using the OpenSearch client, but when I serialize and run the query directly against the cluster, the query works as expected.
I wonder if this bug still exists that was fixed in the ElasticSearch client: client failed to parse completion suggest response · Issue #57 · elastic/elasticsearch-java · GitHub
Configuration:
String suggestionField = "prefix";
int size = 5;
Map<String, FieldSuggester> fieldSuggesters = new HashMap<>();
for (String suggestionField: getSuggestionQueryFields()) {
CompletionSuggester completionSuggester = FieldSuggesterBuilders.completion()
.field(suggestionField)
.size(size)
.skipDuplicates(Boolean.TRUE)
.build();
FieldSuggester fieldSuggester = new FieldSuggester.Builder()
.completion(completionSuggester)
.build();
fieldSuggesters.put(suggestionField + "Suggestion", fieldSuggester);
}
Suggester suggester = new Suggester.Builder()
.suggesters(fieldSuggesters)
.text(suggestionString)
.build();
SearchRequest searchRequest = new SearchRequest.Builder()
.index("my_index_name")
.suggest(suggester)
.size(size)
.build();
if (LOGGER.isDebugEnabled()) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
JacksonJsonpGenerator generator = new JacksonJsonpGenerator(
new JsonFactory().createGenerator(outputStream));
searchRequest.serialize(
generator,
new JacksonJsonpMapper());
generator.close();
String query = outputStream.toString();
LOGGER.debug(query);
}
SearchResponse<MyType> response = this.openSearchClient.search(searchRequest, MyType.class);
Relevant Logs or Screenshots:
The following exception is being thrown (I believe incorrectly, since I am doing completion and not term suggestion):
org.opensearch.client.util.MissingRequiredPropertyException: Missing required property 'TermSuggestOption.score'