diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/core/termvectors/Term.java b/java-client/src/main/java/org/opensearch/client/opensearch/core/termvectors/Term.java index da22db580f..733704de66 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/core/termvectors/Term.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/core/termvectors/Term.java @@ -56,7 +56,7 @@ public class Term implements JsonpSerializable { @Nullable private final Double score; - private final Integer termFreq; + private final Integer termFreq; private final List tokens; @@ -67,11 +67,11 @@ public class Term implements JsonpSerializable { private Term(Builder builder) { - this.docFreq = builder.docFreq; - this.score = builder.score; - this.termFreq = builder.termFreq; - this.tokens = ApiTypeHelper.unmodifiable(builder.tokens); - this.ttf = builder.ttf; + this.docFreq = builder.docFreq; + this.score = builder.score; + this.termFreq = builder.termFreq; + this.tokens = ApiTypeHelper.unmodifiable(builder.tokens); + this.ttf = builder.ttf; } @@ -137,11 +137,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("score"); generator.write(this.score); - } - if (null != this.termFreq) { - generator.writeKey("term_freq"); - generator.write(this.termFreq); - } + } + if (null != this.termFreq) { + generator.writeKey("term_freq"); + generator.write(this.termFreq); + } if (ApiTypeHelper.isDefined(this.tokens)) { generator.writeKey("tokens"); diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/core/termvectors/TermVector.java b/java-client/src/main/java/org/opensearch/client/opensearch/core/termvectors/TermVector.java index 1648e94a89..55b7f0aeff 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/core/termvectors/TermVector.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/core/termvectors/TermVector.java @@ -57,8 +57,8 @@ public class TermVector implements JsonpSerializable { private TermVector(Builder builder) { - this.fieldStatistics = builder.fieldStatistics; - this.terms = ApiTypeHelper.unmodifiableRequired(builder.terms, this, "terms"); + this.fieldStatistics = builder.fieldStatistics; + this.terms = ApiTypeHelper.unmodifiableRequired(builder.terms, this, "terms"); } @@ -91,10 +91,10 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - if (null != this.fieldStatistics) { - generator.writeKey("field_statistics"); - this.fieldStatistics.serialize(generator, mapper); - } + if (null != this.fieldStatistics) { + generator.writeKey("field_statistics"); + this.fieldStatistics.serialize(generator, mapper); + } if (ApiTypeHelper.isDefined(this.terms)) { generator.writeKey("terms"); diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/experiments/ParsingTests.java b/java-client/src/test/java/org/opensearch/client/opensearch/experiments/ParsingTests.java index a5f31ad939..70a598a805 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/experiments/ParsingTests.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/experiments/ParsingTests.java @@ -40,11 +40,11 @@ import org.opensearch.client.opensearch._types.analysis.TokenFilterDefinition; import org.opensearch.client.opensearch._types.analysis.TokenizerBuilders; import org.opensearch.client.opensearch._types.analysis.TokenizerDefinition; -import org.opensearch.client.opensearch.core.TermvectorsResponse; import org.opensearch.client.opensearch._types.mapping.FieldMapping; import org.opensearch.client.opensearch._types.mapping.Property; import org.opensearch.client.opensearch._types.mapping.TermVectorOption; import org.opensearch.client.opensearch._types.mapping.TextProperty; +import org.opensearch.client.opensearch.core.TermvectorsResponse; import org.opensearch.client.opensearch.experiments.api.FooRequest; import org.opensearch.client.opensearch.indices.GetFieldMappingResponse; import org.opensearch.client.opensearch.indices.IndexSettings; @@ -251,26 +251,25 @@ public void testFieldMappingResponse() { assertNotNull(mappings.get(field3Name)); } - + @Test public void testTermvectorsResponseOptionals() { // Build a response without any optionals - final TermvectorsResponse response = TermvectorsResponse.of(b -> b - .index("index") - .id("id") - .version(1) - .found(true) - .took(0) - .termVectors("key1", tvb -> tvb - .terms("term1", tb -> tb - .score(0.3) - ) - ) + final TermvectorsResponse response = TermvectorsResponse.of( + b -> b.index("index") + .id("id") + .version(1) + .found(true) + .took(0) + .termVectors("key1", tvb -> tvb.terms("term1", tb -> tb.score(0.3))) ); String str = toJson(response); - assertEquals("{\"found\":true,\"_id\":\"id\",\"_index\":\"index\"," - +"\"term_vectors\":{\"key1\":{\"terms\":{\"term1\":{\"score\":0.3}}}},\"took\":0,\"_version\":1}", str); + assertEquals( + "{\"found\":true,\"_id\":\"id\",\"_index\":\"index\"," + + "\"term_vectors\":{\"key1\":{\"terms\":{\"term1\":{\"score\":0.3}}}},\"took\":0,\"_version\":1}", + str + ); final TermvectorsResponse response2 = fromJson(str, TermvectorsResponse._DESERIALIZER); assertEquals(response.index(), response2.index());