diff --git a/CHANGELOG.md b/CHANGELOG.md index 66b0e335b5..31dec1fac0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ This section is for maintaining a changelog for all breaking changes for the cli ## [Unreleased 2.x] ### Added +- Add missed fields to PhraseSuggestOption: collapseMatch ([#960](https://github.com/opensearch-project/opensearch-java/pull/960)) ### Dependencies diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/core/search/PhraseSuggestOption.java b/java-client/src/main/java/org/opensearch/client/opensearch/core/search/PhraseSuggestOption.java index 21b2bdee0e..723788bc7e 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/core/search/PhraseSuggestOption.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/core/search/PhraseSuggestOption.java @@ -56,6 +56,9 @@ public class PhraseSuggestOption implements JsonpSerializable { private final double score; + @Nullable + private final Boolean collateMatch; + // --------------------------------------------------------------------------------------------- private PhraseSuggestOption(Builder builder) { @@ -63,6 +66,7 @@ private PhraseSuggestOption(Builder builder) { this.text = ApiTypeHelper.requireNonNull(builder.text, this, "text"); this.highlighted = builder.highlighted; this.score = ApiTypeHelper.requireNonNull(builder.score, this, "score"); + this.collateMatch = builder.collateMatch; } @@ -92,6 +96,13 @@ public final double score() { return this.score; } + /** + * API name: {@code collate_match} + */ + public final Boolean collateMatch() { + return this.collateMatch; + } + /** * Serialize this object to JSON. */ @@ -114,6 +125,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("score"); generator.write(this.score); + if (this.collateMatch != null) { + generator.writeKey("collate_match"); + generator.write(this.collateMatch); + } } // --------------------------------------------------------------------------------------------- @@ -130,6 +145,9 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder
c.query(q -> q.source("{\"match\": {\"{{field_name}}\" : \"{{suggestion}}\"}}")) + .prune(true) + .params(Map.of("field_name", JsonData.of("msg"))) + ) + .build(); FieldSuggester fieldSuggester = new FieldSuggester.Builder().text("design paterns").phrase(phraseSuggester).build(); Suggester suggester = new Suggester.Builder().suggesters(Collections.singletonMap(suggesterName, fieldSuggester)).build(); SearchRequest searchRequest = new SearchRequest.Builder().index(index).suggest(suggester).build(); @@ -785,19 +793,9 @@ public void testPhraseSuggester() throws IOException { assertTrue(response.suggest().get(suggesterName).get(0).isPhrase()); assertNotNull(response.suggest().get(suggesterName).get(0).phrase().options()); assertEquals(response.suggest().get(suggesterName).get(0).phrase().options().get(0).text(), "design patterns"); + assertEquals(response.suggest().get(suggesterName).get(0).phrase().options().get(0).collateMatch(), true); } - // @Test - // public void testValueBodyResponse() throws Exception { - // DiskUsageResponse resp = highLevelClient().indices().diskUsage(b -> b - // .index("*") - // .allowNoIndices(true) - // .runExpensiveTasks(true) - // ); - // - // assertNotNull(resp.valueBody().toJson().asJsonObject().get("_shards")); - // } - public static class AppData { private int intValue;