diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/Time.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/Time.java index 5f60c44b5..ae97518e2 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/Time.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/Time.java @@ -43,7 +43,7 @@ import java.util.function.Function; import javax.annotation.Nullable; -// typedef: _types.Time +// typedef: _types.Duration /** * Whenever durations need to be specified, e.g. for a timeout parameter, the @@ -52,7 +52,8 @@ * @see Documentation * on elastic.co - * @see API specification + * @see API + * specification */ @JsonpDeserializable public class Time implements TaggedUnion, JsonpSerializable { diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/DateHistogramAggregation.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/DateHistogramAggregation.java index aeeb5d0c8..ef480d6b5 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/DateHistogramAggregation.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/DateHistogramAggregation.java @@ -24,6 +24,7 @@ package co.elastic.clients.elasticsearch._types.aggregations; import co.elastic.clients.elasticsearch._types.Script; +import co.elastic.clients.elasticsearch._types.SortOrder; import co.elastic.clients.elasticsearch._types.Time; import co.elastic.clients.elasticsearch.transform.PivotGroupBy; import co.elastic.clients.elasticsearch.transform.PivotGroupByVariant; @@ -34,11 +35,13 @@ import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.NamedValue; import co.elastic.clients.util.ObjectBuilder; import jakarta.json.stream.JsonGenerator; import java.lang.Boolean; import java.lang.Integer; import java.lang.String; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.function.Function; @@ -84,8 +87,7 @@ public class DateHistogramAggregation extends BucketAggregationBase implements A @Nullable private final Time offset; - @Nullable - private final HistogramOrder order; + private final List> order; private final Map params; @@ -113,7 +115,7 @@ private DateHistogramAggregation(Builder builder) { this.minDocCount = builder.minDocCount; this.missing = builder.missing; this.offset = builder.offset; - this.order = builder.order; + this.order = ApiTypeHelper.unmodifiable(builder.order); this.params = ApiTypeHelper.unmodifiable(builder.params); this.script = builder.script; this.timeZone = builder.timeZone; @@ -224,8 +226,7 @@ public final Time offset() { /** * API name: {@code order} */ - @Nullable - public final HistogramOrder order() { + public final List> order() { return this.order; } @@ -312,9 +313,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { this.offset.serialize(generator, mapper); } - if (this.order != null) { + if (ApiTypeHelper.isDefined(this.order)) { generator.writeKey("order"); - this.order.serialize(generator, mapper); + generator.writeStartArray(); + for (NamedValue item0 : this.order) { + generator.writeStartObject(); + generator.writeKey(item0.name()); + item0.value().serialize(generator, mapper); + generator.writeEnd(); + + } + generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.params)) { @@ -386,7 +395,7 @@ public static class Builder extends BucketAggregationBase.AbstractBuilder> order; @Nullable private Map params; @@ -519,17 +528,22 @@ public final Builder offset(Function> fn) { /** * API name: {@code order} + *

+ * Adds all elements of list to order. */ - public final Builder order(@Nullable HistogramOrder value) { - this.order = value; + public final Builder order(List> list) { + this.order = _listAddAll(this.order, list); return this; } /** * API name: {@code order} + *

+ * Adds one or more values to order. */ - public final Builder order(Function> fn) { - return this.order(fn.apply(new HistogramOrder.Builder()).build()); + public final Builder order(NamedValue value, NamedValue... values) { + this.order = _listAdd(this.order, value, values); + return this; } /** @@ -624,7 +638,8 @@ protected static void setupDateHistogramAggregationDeserializer( op.add(Builder::minDocCount, JsonpDeserializer.integerDeserializer(), "min_doc_count"); op.add(Builder::missing, JsonpDeserializer.stringDeserializer(), "missing"); op.add(Builder::offset, Time._DESERIALIZER, "offset"); - op.add(Builder::order, HistogramOrder._DESERIALIZER, "order"); + op.add(Builder::order, + JsonpDeserializer.arrayDeserializer(NamedValue.deserializer(() -> SortOrder._DESERIALIZER)), "order"); op.add(Builder::params, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "params"); op.add(Builder::script, Script._DESERIALIZER, "script"); op.add(Builder::timeZone, JsonpDeserializer.stringDeserializer(), "time_zone"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/HistogramAggregation.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/HistogramAggregation.java index 4ea4c5dff..959cf5604 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/HistogramAggregation.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/HistogramAggregation.java @@ -24,6 +24,7 @@ package co.elastic.clients.elasticsearch._types.aggregations; import co.elastic.clients.elasticsearch._types.Script; +import co.elastic.clients.elasticsearch._types.SortOrder; import co.elastic.clients.elasticsearch.transform.PivotGroupBy; import co.elastic.clients.elasticsearch.transform.PivotGroupByVariant; import co.elastic.clients.json.JsonpDeserializable; @@ -31,12 +32,15 @@ import co.elastic.clients.json.JsonpMapper; import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.NamedValue; import co.elastic.clients.util.ObjectBuilder; import jakarta.json.stream.JsonGenerator; import java.lang.Boolean; import java.lang.Double; import java.lang.Integer; import java.lang.String; +import java.util.List; import java.util.Objects; import java.util.function.Function; import javax.annotation.Nullable; @@ -72,8 +76,7 @@ public class HistogramAggregation extends BucketAggregationBase implements Aggre @Nullable private final Double offset; - @Nullable - private final HistogramOrder order; + private final List> order; @Nullable private final Script script; @@ -96,7 +99,7 @@ private HistogramAggregation(Builder builder) { this.minDocCount = builder.minDocCount; this.missing = builder.missing; this.offset = builder.offset; - this.order = builder.order; + this.order = ApiTypeHelper.unmodifiable(builder.order); this.script = builder.script; this.format = builder.format; this.keyed = builder.keyed; @@ -182,8 +185,7 @@ public final Double offset() { /** * API name: {@code order} */ - @Nullable - public final HistogramOrder order() { + public final List> order() { return this.order; } @@ -249,9 +251,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write(this.offset); } - if (this.order != null) { + if (ApiTypeHelper.isDefined(this.order)) { generator.writeKey("order"); - this.order.serialize(generator, mapper); + generator.writeStartArray(); + for (NamedValue item0 : this.order) { + generator.writeStartObject(); + generator.writeKey(item0.name()); + item0.value().serialize(generator, mapper); + generator.writeEnd(); + + } + generator.writeEnd(); } if (this.script != null) { @@ -303,7 +313,7 @@ public static class Builder extends BucketAggregationBase.AbstractBuilder> order; @Nullable private Script script; @@ -388,17 +398,22 @@ public final Builder offset(@Nullable Double value) { /** * API name: {@code order} + *

+ * Adds all elements of list to order. */ - public final Builder order(@Nullable HistogramOrder value) { - this.order = value; + public final Builder order(List> list) { + this.order = _listAddAll(this.order, list); return this; } /** * API name: {@code order} + *

+ * Adds one or more values to order. */ - public final Builder order(Function> fn) { - return this.order(fn.apply(new HistogramOrder.Builder()).build()); + public final Builder order(NamedValue value, NamedValue... values) { + this.order = _listAdd(this.order, value, values); + return this; } /** @@ -470,7 +485,8 @@ protected static void setupHistogramAggregationDeserializer(ObjectDeserializer SortOrder._DESERIALIZER)), "order"); op.add(Builder::script, Script._DESERIALIZER, "script"); op.add(Builder::format, JsonpDeserializer.stringDeserializer(), "format"); op.add(Builder::keyed, JsonpDeserializer.booleanDeserializer(), "keyed"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/MultiTermsAggregation.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/MultiTermsAggregation.java index 2d8803d78..d2c10f31f 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/MultiTermsAggregation.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/MultiTermsAggregation.java @@ -23,14 +23,19 @@ package co.elastic.clients.elasticsearch._types.aggregations; +import co.elastic.clients.elasticsearch._types.SortOrder; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.NamedValue; import co.elastic.clients.util.ObjectBuilder; import jakarta.json.stream.JsonGenerator; +import java.lang.Boolean; +import java.lang.Integer; +import java.lang.Long; import java.util.List; import java.util.Objects; import java.util.function.Function; @@ -46,6 +51,26 @@ */ @JsonpDeserializable public class MultiTermsAggregation extends BucketAggregationBase implements AggregationVariant { + @Nullable + private final TermsAggregationCollectMode collectMode; + + private final List> order; + + @Nullable + private final Long minDocCount; + + @Nullable + private final Long shardMinDocCount; + + @Nullable + private final Integer shardSize; + + @Nullable + private final Boolean showTermDocCountError; + + @Nullable + private final Integer size; + private final List terms; // --------------------------------------------------------------------------------------------- @@ -53,6 +78,13 @@ public class MultiTermsAggregation extends BucketAggregationBase implements Aggr private MultiTermsAggregation(Builder builder) { super(builder); + this.collectMode = builder.collectMode; + this.order = ApiTypeHelper.unmodifiable(builder.order); + this.minDocCount = builder.minDocCount; + this.shardMinDocCount = builder.shardMinDocCount; + this.shardSize = builder.shardSize; + this.showTermDocCountError = builder.showTermDocCountError; + this.size = builder.size; this.terms = ApiTypeHelper.unmodifiableRequired(builder.terms, this, "terms"); } @@ -69,6 +101,61 @@ public Aggregation.Kind _aggregationKind() { return Aggregation.Kind.MultiTerms; } + /** + * API name: {@code collect_mode} + */ + @Nullable + public final TermsAggregationCollectMode collectMode() { + return this.collectMode; + } + + /** + * API name: {@code order} + */ + public final List> order() { + return this.order; + } + + /** + * API name: {@code min_doc_count} + */ + @Nullable + public final Long minDocCount() { + return this.minDocCount; + } + + /** + * API name: {@code shard_min_doc_count} + */ + @Nullable + public final Long shardMinDocCount() { + return this.shardMinDocCount; + } + + /** + * API name: {@code shard_size} + */ + @Nullable + public final Integer shardSize() { + return this.shardSize; + } + + /** + * API name: {@code show_term_doc_count_error} + */ + @Nullable + public final Boolean showTermDocCountError() { + return this.showTermDocCountError; + } + + /** + * API name: {@code size} + */ + @Nullable + public final Integer size() { + return this.size; + } + /** * Required - API name: {@code terms} */ @@ -79,6 +166,48 @@ public final List terms() { protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { super.serializeInternal(generator, mapper); + if (this.collectMode != null) { + generator.writeKey("collect_mode"); + this.collectMode.serialize(generator, mapper); + } + if (ApiTypeHelper.isDefined(this.order)) { + generator.writeKey("order"); + generator.writeStartArray(); + for (NamedValue item0 : this.order) { + generator.writeStartObject(); + generator.writeKey(item0.name()); + item0.value().serialize(generator, mapper); + generator.writeEnd(); + + } + generator.writeEnd(); + + } + if (this.minDocCount != null) { + generator.writeKey("min_doc_count"); + generator.write(this.minDocCount); + + } + if (this.shardMinDocCount != null) { + generator.writeKey("shard_min_doc_count"); + generator.write(this.shardMinDocCount); + + } + if (this.shardSize != null) { + generator.writeKey("shard_size"); + generator.write(this.shardSize); + + } + if (this.showTermDocCountError != null) { + generator.writeKey("show_term_doc_count_error"); + generator.write(this.showTermDocCountError); + + } + if (this.size != null) { + generator.writeKey("size"); + generator.write(this.size); + + } if (ApiTypeHelper.isDefined(this.terms)) { generator.writeKey("terms"); generator.writeStartArray(); @@ -101,8 +230,97 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends BucketAggregationBase.AbstractBuilder implements ObjectBuilder { + @Nullable + private TermsAggregationCollectMode collectMode; + + @Nullable + private List> order; + + @Nullable + private Long minDocCount; + + @Nullable + private Long shardMinDocCount; + + @Nullable + private Integer shardSize; + + @Nullable + private Boolean showTermDocCountError; + + @Nullable + private Integer size; + private List terms; + /** + * API name: {@code collect_mode} + */ + public final Builder collectMode(@Nullable TermsAggregationCollectMode value) { + this.collectMode = value; + return this; + } + + /** + * API name: {@code order} + *

+ * Adds all elements of list to order. + */ + public final Builder order(List> list) { + this.order = _listAddAll(this.order, list); + return this; + } + + /** + * API name: {@code order} + *

+ * Adds one or more values to order. + */ + public final Builder order(NamedValue value, NamedValue... values) { + this.order = _listAdd(this.order, value, values); + return this; + } + + /** + * API name: {@code min_doc_count} + */ + public final Builder minDocCount(@Nullable Long value) { + this.minDocCount = value; + return this; + } + + /** + * API name: {@code shard_min_doc_count} + */ + public final Builder shardMinDocCount(@Nullable Long value) { + this.shardMinDocCount = value; + return this; + } + + /** + * API name: {@code shard_size} + */ + public final Builder shardSize(@Nullable Integer value) { + this.shardSize = value; + return this; + } + + /** + * API name: {@code show_term_doc_count_error} + */ + public final Builder showTermDocCountError(@Nullable Boolean value) { + this.showTermDocCountError = value; + return this; + } + + /** + * API name: {@code size} + */ + public final Builder size(@Nullable Integer value) { + this.size = value; + return this; + } + /** * Required - API name: {@code terms} *

@@ -160,6 +378,14 @@ public MultiTermsAggregation build() { protected static void setupMultiTermsAggregationDeserializer(ObjectDeserializer op) { BucketAggregationBase.setupBucketAggregationBaseDeserializer(op); + op.add(Builder::collectMode, TermsAggregationCollectMode._DESERIALIZER, "collect_mode"); + op.add(Builder::order, + JsonpDeserializer.arrayDeserializer(NamedValue.deserializer(() -> SortOrder._DESERIALIZER)), "order"); + op.add(Builder::minDocCount, JsonpDeserializer.longDeserializer(), "min_doc_count"); + op.add(Builder::shardMinDocCount, JsonpDeserializer.longDeserializer(), "shard_min_doc_count"); + op.add(Builder::shardSize, JsonpDeserializer.integerDeserializer(), "shard_size"); + op.add(Builder::showTermDocCountError, JsonpDeserializer.booleanDeserializer(), "show_term_doc_count_error"); + op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::terms, JsonpDeserializer.arrayDeserializer(MultiTermLookup._DESERIALIZER), "terms"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/TermsAggregation.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/TermsAggregation.java index b6b2e82e9..fe795cf40 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/TermsAggregation.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/TermsAggregation.java @@ -34,13 +34,13 @@ import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.NamedValue; import co.elastic.clients.util.ObjectBuilder; import jakarta.json.stream.JsonGenerator; import java.lang.Boolean; import java.lang.Integer; import java.lang.String; import java.util.List; -import java.util.Map; import java.util.Objects; import java.util.function.Function; import javax.annotation.Nullable; @@ -85,7 +85,7 @@ public class TermsAggregation extends BucketAggregationBase implements Aggregati @Nullable private final String valueType; - private final List> order; + private final List> order; @Nullable private final Script script; @@ -225,7 +225,7 @@ public final String valueType() { /** * API name: {@code order} */ - public final List> order() { + public final List> order() { return this.order; } @@ -314,14 +314,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.order)) { generator.writeKey("order"); generator.writeStartArray(); - for (Map item0 : this.order) { + for (NamedValue item0 : this.order) { generator.writeStartObject(); - if (item0 != null) { - for (Map.Entry item1 : item0.entrySet()) { - generator.writeKey(item1.getKey()); - item1.getValue().serialize(generator, mapper); - } - } + generator.writeKey(item0.name()); + item0.value().serialize(generator, mapper); generator.writeEnd(); } @@ -391,7 +387,7 @@ public static class Builder extends BucketAggregationBase.AbstractBuilder> order; + private List> order; @Nullable private Script script; @@ -543,7 +539,7 @@ public final Builder valueType(@Nullable String value) { *

* Adds all elements of list to order. */ - public final Builder order(List> list) { + public final Builder order(List> list) { this.order = _listAddAll(this.order, list); return this; } @@ -553,7 +549,7 @@ public final Builder order(List> list) { *

* Adds one or more values to order. */ - public final Builder order(Map value, Map... values) { + public final Builder order(NamedValue value, NamedValue... values) { this.order = _listAdd(this.order, value, values); return this; } @@ -636,8 +632,7 @@ protected static void setupTermsAggregationDeserializer(ObjectDeserializer SortOrder._DESERIALIZER)), "order"); op.add(Builder::script, Script._DESERIALIZER, "script"); op.add(Builder::shardSize, JsonpDeserializer.integerDeserializer(), "shard_size"); op.add(Builder::showTermDocCountError, JsonpDeserializer.booleanDeserializer(), "show_term_doc_count_error"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/AsciiFoldingTokenFilter.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/AsciiFoldingTokenFilter.java index 56876efba..c5ee53be2 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/AsciiFoldingTokenFilter.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/AsciiFoldingTokenFilter.java @@ -28,12 +28,12 @@ import co.elastic.clients.json.JsonpMapper; import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; -import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; import jakarta.json.stream.JsonGenerator; import java.lang.Boolean; import java.util.Objects; import java.util.function.Function; +import javax.annotation.Nullable; // typedef: _types.analysis.AsciiFoldingTokenFilter @@ -45,14 +45,15 @@ */ @JsonpDeserializable public class AsciiFoldingTokenFilter extends TokenFilterBase implements TokenFilterDefinitionVariant { - private final boolean preserveOriginal; + @Nullable + private final Boolean preserveOriginal; // --------------------------------------------------------------------------------------------- private AsciiFoldingTokenFilter(Builder builder) { super(builder); - this.preserveOriginal = ApiTypeHelper.requireNonNull(builder.preserveOriginal, this, "preserveOriginal"); + this.preserveOriginal = builder.preserveOriginal; } @@ -69,9 +70,10 @@ public TokenFilterDefinition.Kind _tokenFilterDefinitionKind() { } /** - * Required - API name: {@code preserve_original} + * API name: {@code preserve_original} */ - public final boolean preserveOriginal() { + @Nullable + public final Boolean preserveOriginal() { return this.preserveOriginal; } @@ -79,8 +81,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write("type", "asciifolding"); super.serializeInternal(generator, mapper); - generator.writeKey("preserve_original"); - generator.write(this.preserveOriginal); + if (this.preserveOriginal != null) { + generator.writeKey("preserve_original"); + generator.write(this.preserveOriginal); + + } } @@ -93,12 +98,13 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends TokenFilterBase.AbstractBuilder implements ObjectBuilder { + @Nullable private Boolean preserveOriginal; /** - * Required - API name: {@code preserve_original} + * API name: {@code preserve_original} */ - public final Builder preserveOriginal(boolean value) { + public final Builder preserveOriginal(@Nullable Boolean value) { this.preserveOriginal = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/DelimitedPayloadTokenFilter.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/DelimitedPayloadTokenFilter.java index cc13d54e8..9fc23fde2 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/DelimitedPayloadTokenFilter.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/DelimitedPayloadTokenFilter.java @@ -28,7 +28,6 @@ import co.elastic.clients.json.JsonpMapper; import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; -import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; import jakarta.json.stream.JsonGenerator; import java.lang.String; @@ -46,8 +45,10 @@ */ @JsonpDeserializable public class DelimitedPayloadTokenFilter extends TokenFilterBase implements TokenFilterDefinitionVariant { + @Nullable private final String delimiter; + @Nullable private final DelimitedPayloadEncoding encoding; // --------------------------------------------------------------------------------------------- @@ -55,8 +56,8 @@ public class DelimitedPayloadTokenFilter extends TokenFilterBase implements Toke private DelimitedPayloadTokenFilter(Builder builder) { super(builder); - this.delimiter = ApiTypeHelper.requireNonNull(builder.delimiter, this, "delimiter"); - this.encoding = ApiTypeHelper.requireNonNull(builder.encoding, this, "encoding"); + this.delimiter = builder.delimiter; + this.encoding = builder.encoding; } @@ -73,15 +74,17 @@ public TokenFilterDefinition.Kind _tokenFilterDefinitionKind() { } /** - * Required - API name: {@code delimiter} + * API name: {@code delimiter} */ + @Nullable public final String delimiter() { return this.delimiter; } /** - * Required - API name: {@code encoding} + * API name: {@code encoding} */ + @Nullable public final DelimitedPayloadEncoding encoding() { return this.encoding; } @@ -90,11 +93,15 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write("type", "delimited_payload"); super.serializeInternal(generator, mapper); - generator.writeKey("delimiter"); - generator.write(this.delimiter); + if (this.delimiter != null) { + generator.writeKey("delimiter"); + generator.write(this.delimiter); - generator.writeKey("encoding"); - this.encoding.serialize(generator, mapper); + } + if (this.encoding != null) { + generator.writeKey("encoding"); + this.encoding.serialize(generator, mapper); + } } @@ -107,22 +114,24 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends TokenFilterBase.AbstractBuilder implements ObjectBuilder { + @Nullable private String delimiter; + @Nullable private DelimitedPayloadEncoding encoding; /** - * Required - API name: {@code delimiter} + * API name: {@code delimiter} */ - public final Builder delimiter(String value) { + public final Builder delimiter(@Nullable String value) { this.delimiter = value; return this; } /** - * Required - API name: {@code encoding} + * API name: {@code encoding} */ - public final Builder encoding(DelimitedPayloadEncoding value) { + public final Builder encoding(@Nullable DelimitedPayloadEncoding value) { this.encoding = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/EdgeNGramTokenFilter.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/EdgeNGramTokenFilter.java index 13d7dee95..6ee6cb075 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/EdgeNGramTokenFilter.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/EdgeNGramTokenFilter.java @@ -28,7 +28,6 @@ import co.elastic.clients.json.JsonpMapper; import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; -import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; import jakarta.json.stream.JsonGenerator; import java.lang.Boolean; @@ -47,9 +46,11 @@ */ @JsonpDeserializable public class EdgeNGramTokenFilter extends TokenFilterBase implements TokenFilterDefinitionVariant { - private final int maxGram; + @Nullable + private final Integer maxGram; - private final int minGram; + @Nullable + private final Integer minGram; @Nullable private final EdgeNGramSide side; @@ -62,8 +63,8 @@ public class EdgeNGramTokenFilter extends TokenFilterBase implements TokenFilter private EdgeNGramTokenFilter(Builder builder) { super(builder); - this.maxGram = ApiTypeHelper.requireNonNull(builder.maxGram, this, "maxGram"); - this.minGram = ApiTypeHelper.requireNonNull(builder.minGram, this, "minGram"); + this.maxGram = builder.maxGram; + this.minGram = builder.minGram; this.side = builder.side; this.preserveOriginal = builder.preserveOriginal; @@ -82,16 +83,18 @@ public TokenFilterDefinition.Kind _tokenFilterDefinitionKind() { } /** - * Required - API name: {@code max_gram} + * API name: {@code max_gram} */ - public final int maxGram() { + @Nullable + public final Integer maxGram() { return this.maxGram; } /** - * Required - API name: {@code min_gram} + * API name: {@code min_gram} */ - public final int minGram() { + @Nullable + public final Integer minGram() { return this.minGram; } @@ -115,12 +118,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write("type", "edge_ngram"); super.serializeInternal(generator, mapper); - generator.writeKey("max_gram"); - generator.write(this.maxGram); + if (this.maxGram != null) { + generator.writeKey("max_gram"); + generator.write(this.maxGram); - generator.writeKey("min_gram"); - generator.write(this.minGram); + } + if (this.minGram != null) { + generator.writeKey("min_gram"); + generator.write(this.minGram); + } if (this.side != null) { generator.writeKey("side"); this.side.serialize(generator, mapper); @@ -142,8 +149,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends TokenFilterBase.AbstractBuilder implements ObjectBuilder { + @Nullable private Integer maxGram; + @Nullable private Integer minGram; @Nullable @@ -153,17 +162,17 @@ public static class Builder extends TokenFilterBase.AbstractBuilder private Boolean preserveOriginal; /** - * Required - API name: {@code max_gram} + * API name: {@code max_gram} */ - public final Builder maxGram(int value) { + public final Builder maxGram(@Nullable Integer value) { this.maxGram = value; return this; } /** - * Required - API name: {@code min_gram} + * API name: {@code min_gram} */ - public final Builder minGram(int value) { + public final Builder minGram(@Nullable Integer value) { this.minGram = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/ElisionTokenFilter.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/ElisionTokenFilter.java index 3c127ec98..3505500f5 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/ElisionTokenFilter.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/ElisionTokenFilter.java @@ -50,15 +50,20 @@ public class ElisionTokenFilter extends TokenFilterBase implements TokenFilterDefinitionVariant { private final List articles; - private final boolean articlesCase; + @Nullable + private final String articlesPath; + + @Nullable + private final Boolean articlesCase; // --------------------------------------------------------------------------------------------- private ElisionTokenFilter(Builder builder) { super(builder); - this.articles = ApiTypeHelper.unmodifiableRequired(builder.articles, this, "articles"); - this.articlesCase = ApiTypeHelper.requireNonNull(builder.articlesCase, this, "articlesCase"); + this.articles = ApiTypeHelper.unmodifiable(builder.articles); + this.articlesPath = builder.articlesPath; + this.articlesCase = builder.articlesCase; } @@ -75,16 +80,25 @@ public TokenFilterDefinition.Kind _tokenFilterDefinitionKind() { } /** - * Required - API name: {@code articles} + * API name: {@code articles} */ public final List articles() { return this.articles; } /** - * Required - API name: {@code articles_case} + * API name: {@code articles_path} + */ + @Nullable + public final String articlesPath() { + return this.articlesPath; + } + + /** + * API name: {@code articles_case} */ - public final boolean articlesCase() { + @Nullable + public final Boolean articlesCase() { return this.articlesCase; } @@ -102,8 +116,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeEnd(); } - generator.writeKey("articles_case"); - generator.write(this.articlesCase); + if (this.articlesPath != null) { + generator.writeKey("articles_path"); + generator.write(this.articlesPath); + + } + if (this.articlesCase != null) { + generator.writeKey("articles_case"); + generator.write(this.articlesCase); + + } } @@ -116,12 +138,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends TokenFilterBase.AbstractBuilder implements ObjectBuilder { + @Nullable private List articles; + @Nullable + private String articlesPath; + + @Nullable private Boolean articlesCase; /** - * Required - API name: {@code articles} + * API name: {@code articles} *

* Adds all elements of list to articles. */ @@ -131,7 +158,7 @@ public final Builder articles(List list) { } /** - * Required - API name: {@code articles} + * API name: {@code articles} *

* Adds one or more values to articles. */ @@ -141,9 +168,17 @@ public final Builder articles(String value, String... values) { } /** - * Required - API name: {@code articles_case} + * API name: {@code articles_path} + */ + public final Builder articlesPath(@Nullable String value) { + this.articlesPath = value; + return this; + } + + /** + * API name: {@code articles_case} */ - public final Builder articlesCase(boolean value) { + public final Builder articlesCase(@Nullable Boolean value) { this.articlesCase = value; return this; } @@ -178,6 +213,7 @@ protected static void setupElisionTokenFilterDeserializer(ObjectDeserializer implements ObjectBuilder { + @Nullable private Integer maxOutputSize; + @Nullable private String separator; /** - * Required - API name: {@code max_output_size} + * API name: {@code max_output_size} */ - public final Builder maxOutputSize(int value) { + public final Builder maxOutputSize(@Nullable Integer value) { this.maxOutputSize = value; return this; } /** - * Required - API name: {@code separator} + * API name: {@code separator} */ - public final Builder separator(String value) { + public final Builder separator(@Nullable String value) { this.separator = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/HunspellTokenFilter.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/HunspellTokenFilter.java index f5f2fe90f..c32140f2a 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/HunspellTokenFilter.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/HunspellTokenFilter.java @@ -47,23 +47,26 @@ */ @JsonpDeserializable public class HunspellTokenFilter extends TokenFilterBase implements TokenFilterDefinitionVariant { - private final boolean dedup; + @Nullable + private final Boolean dedup; + @Nullable private final String dictionary; private final String locale; - private final boolean longestOnly; + @Nullable + private final Boolean longestOnly; // --------------------------------------------------------------------------------------------- private HunspellTokenFilter(Builder builder) { super(builder); - this.dedup = ApiTypeHelper.requireNonNull(builder.dedup, this, "dedup"); - this.dictionary = ApiTypeHelper.requireNonNull(builder.dictionary, this, "dictionary"); + this.dedup = builder.dedup; + this.dictionary = builder.dictionary; this.locale = ApiTypeHelper.requireNonNull(builder.locale, this, "locale"); - this.longestOnly = ApiTypeHelper.requireNonNull(builder.longestOnly, this, "longestOnly"); + this.longestOnly = builder.longestOnly; } @@ -80,15 +83,17 @@ public TokenFilterDefinition.Kind _tokenFilterDefinitionKind() { } /** - * Required - API name: {@code dedup} + * API name: {@code dedup} */ - public final boolean dedup() { + @Nullable + public final Boolean dedup() { return this.dedup; } /** - * Required - API name: {@code dictionary} + * API name: {@code dictionary} */ + @Nullable public final String dictionary() { return this.dictionary; } @@ -101,9 +106,10 @@ public final String locale() { } /** - * Required - API name: {@code longest_only} + * API name: {@code longest_only} */ - public final boolean longestOnly() { + @Nullable + public final Boolean longestOnly() { return this.longestOnly; } @@ -111,17 +117,24 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write("type", "hunspell"); super.serializeInternal(generator, mapper); - generator.writeKey("dedup"); - generator.write(this.dedup); + if (this.dedup != null) { + generator.writeKey("dedup"); + generator.write(this.dedup); - generator.writeKey("dictionary"); - generator.write(this.dictionary); + } + if (this.dictionary != null) { + generator.writeKey("dictionary"); + generator.write(this.dictionary); + } generator.writeKey("locale"); generator.write(this.locale); - generator.writeKey("longest_only"); - generator.write(this.longestOnly); + if (this.longestOnly != null) { + generator.writeKey("longest_only"); + generator.write(this.longestOnly); + + } } @@ -134,26 +147,29 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends TokenFilterBase.AbstractBuilder implements ObjectBuilder { + @Nullable private Boolean dedup; + @Nullable private String dictionary; private String locale; + @Nullable private Boolean longestOnly; /** - * Required - API name: {@code dedup} + * API name: {@code dedup} */ - public final Builder dedup(boolean value) { + public final Builder dedup(@Nullable Boolean value) { this.dedup = value; return this; } /** - * Required - API name: {@code dictionary} + * API name: {@code dictionary} */ - public final Builder dictionary(String value) { + public final Builder dictionary(@Nullable String value) { this.dictionary = value; return this; } @@ -167,9 +183,9 @@ public final Builder locale(String value) { } /** - * Required - API name: {@code longest_only} + * API name: {@code longest_only} */ - public final Builder longestOnly(boolean value) { + public final Builder longestOnly(@Nullable Boolean value) { this.longestOnly = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/LengthTokenFilter.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/LengthTokenFilter.java index 4e6c5dd9f..0d6f69e13 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/LengthTokenFilter.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/LengthTokenFilter.java @@ -28,12 +28,12 @@ import co.elastic.clients.json.JsonpMapper; import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; -import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; import jakarta.json.stream.JsonGenerator; import java.lang.Integer; import java.util.Objects; import java.util.function.Function; +import javax.annotation.Nullable; // typedef: _types.analysis.LengthTokenFilter @@ -45,17 +45,19 @@ */ @JsonpDeserializable public class LengthTokenFilter extends TokenFilterBase implements TokenFilterDefinitionVariant { - private final int max; + @Nullable + private final Integer max; - private final int min; + @Nullable + private final Integer min; // --------------------------------------------------------------------------------------------- private LengthTokenFilter(Builder builder) { super(builder); - this.max = ApiTypeHelper.requireNonNull(builder.max, this, "max"); - this.min = ApiTypeHelper.requireNonNull(builder.min, this, "min"); + this.max = builder.max; + this.min = builder.min; } @@ -72,16 +74,18 @@ public TokenFilterDefinition.Kind _tokenFilterDefinitionKind() { } /** - * Required - API name: {@code max} + * API name: {@code max} */ - public final int max() { + @Nullable + public final Integer max() { return this.max; } /** - * Required - API name: {@code min} + * API name: {@code min} */ - public final int min() { + @Nullable + public final Integer min() { return this.min; } @@ -89,11 +93,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write("type", "length"); super.serializeInternal(generator, mapper); - generator.writeKey("max"); - generator.write(this.max); + if (this.max != null) { + generator.writeKey("max"); + generator.write(this.max); - generator.writeKey("min"); - generator.write(this.min); + } + if (this.min != null) { + generator.writeKey("min"); + generator.write(this.min); + + } } @@ -106,22 +115,24 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends TokenFilterBase.AbstractBuilder implements ObjectBuilder { + @Nullable private Integer max; + @Nullable private Integer min; /** - * Required - API name: {@code max} + * API name: {@code max} */ - public final Builder max(int value) { + public final Builder max(@Nullable Integer value) { this.max = value; return this; } /** - * Required - API name: {@code min} + * API name: {@code min} */ - public final Builder min(int value) { + public final Builder min(@Nullable Integer value) { this.min = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/LimitTokenCountTokenFilter.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/LimitTokenCountTokenFilter.java index 6abc0754a..e035c944d 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/LimitTokenCountTokenFilter.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/LimitTokenCountTokenFilter.java @@ -28,13 +28,13 @@ import co.elastic.clients.json.JsonpMapper; import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; -import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; import jakarta.json.stream.JsonGenerator; import java.lang.Boolean; import java.lang.Integer; import java.util.Objects; import java.util.function.Function; +import javax.annotation.Nullable; // typedef: _types.analysis.LimitTokenCountTokenFilter @@ -46,17 +46,19 @@ */ @JsonpDeserializable public class LimitTokenCountTokenFilter extends TokenFilterBase implements TokenFilterDefinitionVariant { - private final boolean consumeAllTokens; + @Nullable + private final Boolean consumeAllTokens; - private final int maxTokenCount; + @Nullable + private final Integer maxTokenCount; // --------------------------------------------------------------------------------------------- private LimitTokenCountTokenFilter(Builder builder) { super(builder); - this.consumeAllTokens = ApiTypeHelper.requireNonNull(builder.consumeAllTokens, this, "consumeAllTokens"); - this.maxTokenCount = ApiTypeHelper.requireNonNull(builder.maxTokenCount, this, "maxTokenCount"); + this.consumeAllTokens = builder.consumeAllTokens; + this.maxTokenCount = builder.maxTokenCount; } @@ -73,16 +75,18 @@ public TokenFilterDefinition.Kind _tokenFilterDefinitionKind() { } /** - * Required - API name: {@code consume_all_tokens} + * API name: {@code consume_all_tokens} */ - public final boolean consumeAllTokens() { + @Nullable + public final Boolean consumeAllTokens() { return this.consumeAllTokens; } /** - * Required - API name: {@code max_token_count} + * API name: {@code max_token_count} */ - public final int maxTokenCount() { + @Nullable + public final Integer maxTokenCount() { return this.maxTokenCount; } @@ -90,11 +94,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write("type", "limit"); super.serializeInternal(generator, mapper); - generator.writeKey("consume_all_tokens"); - generator.write(this.consumeAllTokens); + if (this.consumeAllTokens != null) { + generator.writeKey("consume_all_tokens"); + generator.write(this.consumeAllTokens); - generator.writeKey("max_token_count"); - generator.write(this.maxTokenCount); + } + if (this.maxTokenCount != null) { + generator.writeKey("max_token_count"); + generator.write(this.maxTokenCount); + + } } @@ -107,22 +116,24 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends TokenFilterBase.AbstractBuilder implements ObjectBuilder { + @Nullable private Boolean consumeAllTokens; + @Nullable private Integer maxTokenCount; /** - * Required - API name: {@code consume_all_tokens} + * API name: {@code consume_all_tokens} */ - public final Builder consumeAllTokens(boolean value) { + public final Builder consumeAllTokens(@Nullable Boolean value) { this.consumeAllTokens = value; return this; } /** - * Required - API name: {@code max_token_count} + * API name: {@code max_token_count} */ - public final Builder maxTokenCount(int value) { + public final Builder maxTokenCount(@Nullable Integer value) { this.maxTokenCount = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/MultiplexerTokenFilter.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/MultiplexerTokenFilter.java index 88357e32d..8a221a22d 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/MultiplexerTokenFilter.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/MultiplexerTokenFilter.java @@ -50,7 +50,8 @@ public class MultiplexerTokenFilter extends TokenFilterBase implements TokenFilterDefinitionVariant { private final List filters; - private final boolean preserveOriginal; + @Nullable + private final Boolean preserveOriginal; // --------------------------------------------------------------------------------------------- @@ -58,7 +59,7 @@ private MultiplexerTokenFilter(Builder builder) { super(builder); this.filters = ApiTypeHelper.unmodifiableRequired(builder.filters, this, "filters"); - this.preserveOriginal = ApiTypeHelper.requireNonNull(builder.preserveOriginal, this, "preserveOriginal"); + this.preserveOriginal = builder.preserveOriginal; } @@ -82,9 +83,10 @@ public final List filters() { } /** - * Required - API name: {@code preserve_original} + * API name: {@code preserve_original} */ - public final boolean preserveOriginal() { + @Nullable + public final Boolean preserveOriginal() { return this.preserveOriginal; } @@ -102,8 +104,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeEnd(); } - generator.writeKey("preserve_original"); - generator.write(this.preserveOriginal); + if (this.preserveOriginal != null) { + generator.writeKey("preserve_original"); + generator.write(this.preserveOriginal); + + } } @@ -118,6 +123,7 @@ public static class Builder extends TokenFilterBase.AbstractBuilder ObjectBuilder { private List filters; + @Nullable private Boolean preserveOriginal; /** @@ -141,9 +147,9 @@ public final Builder filters(String value, String... values) { } /** - * Required - API name: {@code preserve_original} + * API name: {@code preserve_original} */ - public final Builder preserveOriginal(boolean value) { + public final Builder preserveOriginal(@Nullable Boolean value) { this.preserveOriginal = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/NoriPartOfSpeechTokenFilter.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/NoriPartOfSpeechTokenFilter.java index 67c04934b..56092eb10 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/NoriPartOfSpeechTokenFilter.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/NoriPartOfSpeechTokenFilter.java @@ -54,7 +54,7 @@ public class NoriPartOfSpeechTokenFilter extends TokenFilterBase implements Toke private NoriPartOfSpeechTokenFilter(Builder builder) { super(builder); - this.stoptags = ApiTypeHelper.unmodifiableRequired(builder.stoptags, this, "stoptags"); + this.stoptags = ApiTypeHelper.unmodifiable(builder.stoptags); } @@ -71,7 +71,7 @@ public TokenFilterDefinition.Kind _tokenFilterDefinitionKind() { } /** - * Required - API name: {@code stoptags} + * API name: {@code stoptags} */ public final List stoptags() { return this.stoptags; @@ -103,10 +103,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends TokenFilterBase.AbstractBuilder implements ObjectBuilder { + @Nullable private List stoptags; /** - * Required - API name: {@code stoptags} + * API name: {@code stoptags} *

* Adds all elements of list to stoptags. */ @@ -116,7 +117,7 @@ public final Builder stoptags(List list) { } /** - * Required - API name: {@code stoptags} + * API name: {@code stoptags} *

* Adds one or more values to stoptags. */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/PatternCaptureTokenFilter.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/PatternCaptureTokenFilter.java index 172c8126e..5b2d569de 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/PatternCaptureTokenFilter.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/PatternCaptureTokenFilter.java @@ -50,7 +50,8 @@ public class PatternCaptureTokenFilter extends TokenFilterBase implements TokenFilterDefinitionVariant { private final List patterns; - private final boolean preserveOriginal; + @Nullable + private final Boolean preserveOriginal; // --------------------------------------------------------------------------------------------- @@ -58,7 +59,7 @@ private PatternCaptureTokenFilter(Builder builder) { super(builder); this.patterns = ApiTypeHelper.unmodifiableRequired(builder.patterns, this, "patterns"); - this.preserveOriginal = ApiTypeHelper.requireNonNull(builder.preserveOriginal, this, "preserveOriginal"); + this.preserveOriginal = builder.preserveOriginal; } @@ -82,9 +83,10 @@ public final List patterns() { } /** - * Required - API name: {@code preserve_original} + * API name: {@code preserve_original} */ - public final boolean preserveOriginal() { + @Nullable + public final Boolean preserveOriginal() { return this.preserveOriginal; } @@ -102,8 +104,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeEnd(); } - generator.writeKey("preserve_original"); - generator.write(this.preserveOriginal); + if (this.preserveOriginal != null) { + generator.writeKey("preserve_original"); + generator.write(this.preserveOriginal); + + } } @@ -118,6 +123,7 @@ public static class Builder extends TokenFilterBase.AbstractBuilder ObjectBuilder { private List patterns; + @Nullable private Boolean preserveOriginal; /** @@ -141,9 +147,9 @@ public final Builder patterns(String value, String... values) { } /** - * Required - API name: {@code preserve_original} + * API name: {@code preserve_original} */ - public final Builder preserveOriginal(boolean value) { + public final Builder preserveOriginal(@Nullable Boolean value) { this.preserveOriginal = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/PatternReplaceTokenFilter.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/PatternReplaceTokenFilter.java index c5f92cb04..81778fbc4 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/PatternReplaceTokenFilter.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/PatternReplaceTokenFilter.java @@ -31,6 +31,7 @@ import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; import jakarta.json.stream.JsonGenerator; +import java.lang.Boolean; import java.lang.String; import java.util.Objects; import java.util.function.Function; @@ -46,10 +47,15 @@ */ @JsonpDeserializable public class PatternReplaceTokenFilter extends TokenFilterBase implements TokenFilterDefinitionVariant { + @Nullable + private final Boolean all; + + @Nullable private final String flags; private final String pattern; + @Nullable private final String replacement; // --------------------------------------------------------------------------------------------- @@ -57,9 +63,10 @@ public class PatternReplaceTokenFilter extends TokenFilterBase implements TokenF private PatternReplaceTokenFilter(Builder builder) { super(builder); - this.flags = ApiTypeHelper.requireNonNull(builder.flags, this, "flags"); + this.all = builder.all; + this.flags = builder.flags; this.pattern = ApiTypeHelper.requireNonNull(builder.pattern, this, "pattern"); - this.replacement = ApiTypeHelper.requireNonNull(builder.replacement, this, "replacement"); + this.replacement = builder.replacement; } @@ -76,8 +83,17 @@ public TokenFilterDefinition.Kind _tokenFilterDefinitionKind() { } /** - * Required - API name: {@code flags} + * API name: {@code all} + */ + @Nullable + public final Boolean all() { + return this.all; + } + + /** + * API name: {@code flags} */ + @Nullable public final String flags() { return this.flags; } @@ -90,8 +106,9 @@ public final String pattern() { } /** - * Required - API name: {@code replacement} + * API name: {@code replacement} */ + @Nullable public final String replacement() { return this.replacement; } @@ -100,14 +117,24 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write("type", "pattern_replace"); super.serializeInternal(generator, mapper); - generator.writeKey("flags"); - generator.write(this.flags); + if (this.all != null) { + generator.writeKey("all"); + generator.write(this.all); + + } + if (this.flags != null) { + generator.writeKey("flags"); + generator.write(this.flags); + } generator.writeKey("pattern"); generator.write(this.pattern); - generator.writeKey("replacement"); - generator.write(this.replacement); + if (this.replacement != null) { + generator.writeKey("replacement"); + generator.write(this.replacement); + + } } @@ -120,16 +147,29 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends TokenFilterBase.AbstractBuilder implements ObjectBuilder { + @Nullable + private Boolean all; + + @Nullable private String flags; private String pattern; + @Nullable private String replacement; /** - * Required - API name: {@code flags} + * API name: {@code all} + */ + public final Builder all(@Nullable Boolean value) { + this.all = value; + return this; + } + + /** + * API name: {@code flags} */ - public final Builder flags(String value) { + public final Builder flags(@Nullable String value) { this.flags = value; return this; } @@ -143,9 +183,9 @@ public final Builder pattern(String value) { } /** - * Required - API name: {@code replacement} + * API name: {@code replacement} */ - public final Builder replacement(String value) { + public final Builder replacement(@Nullable String value) { this.replacement = value; return this; } @@ -179,6 +219,7 @@ public PatternReplaceTokenFilter build() { protected static void setupPatternReplaceTokenFilterDeserializer( ObjectDeserializer op) { TokenFilterBase.setupTokenFilterBaseDeserializer(op); + op.add(Builder::all, JsonpDeserializer.booleanDeserializer(), "all"); op.add(Builder::flags, JsonpDeserializer.stringDeserializer(), "flags"); op.add(Builder::pattern, JsonpDeserializer.stringDeserializer(), "pattern"); op.add(Builder::replacement, JsonpDeserializer.stringDeserializer(), "replacement"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/StopTokenFilter.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/StopTokenFilter.java index e62c3c906..ddde59ea0 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/StopTokenFilter.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/StopTokenFilter.java @@ -66,7 +66,7 @@ private StopTokenFilter(Builder builder) { this.ignoreCase = builder.ignoreCase; this.removeTrailing = builder.removeTrailing; - this.stopwords = ApiTypeHelper.unmodifiableRequired(builder.stopwords, this, "stopwords"); + this.stopwords = ApiTypeHelper.unmodifiable(builder.stopwords); this.stopwordsPath = builder.stopwordsPath; } @@ -100,7 +100,7 @@ public final Boolean removeTrailing() { } /** - * Required - API name: {@code stopwords} + * API name: {@code stopwords} */ public final List stopwords() { return this.stopwords; @@ -161,6 +161,7 @@ public static class Builder extends TokenFilterBase.AbstractBuilder @Nullable private Boolean removeTrailing; + @Nullable private List stopwords; @Nullable @@ -183,7 +184,7 @@ public final Builder removeTrailing(@Nullable Boolean value) { } /** - * Required - API name: {@code stopwords} + * API name: {@code stopwords} *

* Adds all elements of list to stopwords. */ @@ -193,7 +194,7 @@ public final Builder stopwords(List list) { } /** - * Required - API name: {@code stopwords} + * API name: {@code stopwords} *

* Adds one or more values to stopwords. */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/TruncateTokenFilter.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/TruncateTokenFilter.java index a80a50148..c297f59f1 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/TruncateTokenFilter.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/TruncateTokenFilter.java @@ -28,12 +28,12 @@ import co.elastic.clients.json.JsonpMapper; import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; -import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; import jakarta.json.stream.JsonGenerator; import java.lang.Integer; import java.util.Objects; import java.util.function.Function; +import javax.annotation.Nullable; // typedef: _types.analysis.TruncateTokenFilter @@ -45,14 +45,15 @@ */ @JsonpDeserializable public class TruncateTokenFilter extends TokenFilterBase implements TokenFilterDefinitionVariant { - private final int length; + @Nullable + private final Integer length; // --------------------------------------------------------------------------------------------- private TruncateTokenFilter(Builder builder) { super(builder); - this.length = ApiTypeHelper.requireNonNull(builder.length, this, "length"); + this.length = builder.length; } @@ -69,9 +70,10 @@ public TokenFilterDefinition.Kind _tokenFilterDefinitionKind() { } /** - * Required - API name: {@code length} + * API name: {@code length} */ - public final int length() { + @Nullable + public final Integer length() { return this.length; } @@ -79,8 +81,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write("type", "truncate"); super.serializeInternal(generator, mapper); - generator.writeKey("length"); - generator.write(this.length); + if (this.length != null) { + generator.writeKey("length"); + generator.write(this.length); + + } } @@ -93,12 +98,13 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends TokenFilterBase.AbstractBuilder implements ObjectBuilder { + @Nullable private Integer length; /** - * Required - API name: {@code length} + * API name: {@code length} */ - public final Builder length(int value) { + public final Builder length(@Nullable Integer value) { this.length = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/FieldMapping.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/FieldMapping.java index 88f80aeeb..5c699b03d 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/FieldMapping.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/mapping/FieldMapping.java @@ -49,9 +49,6 @@ */ @JsonpDeserializable public class FieldMapping implements JsonpSerializable { - // Single key dictionary - private final String field; - private final String fullName; private final Map mapping; @@ -60,8 +57,6 @@ public class FieldMapping implements JsonpSerializable { private FieldMapping(Builder builder) { - this.field = ApiTypeHelper.requireNonNull(builder.field, this, "field"); - this.fullName = ApiTypeHelper.requireNonNull(builder.fullName, this, "fullName"); this.mapping = ApiTypeHelper.unmodifiableRequired(builder.mapping, this, "mapping"); @@ -71,13 +66,6 @@ public static FieldMapping of(Function> fn) return fn.apply(new Builder()).build(); } - /** - * Required - The target field - */ - public final String field() { - return this.field; - } - /** * Required - API name: {@code full_name} */ @@ -102,7 +90,6 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(this.field); generator.writeKey("full_name"); generator.write(this.fullName); @@ -119,8 +106,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } - generator.writeEnd(); - } @Override @@ -135,16 +120,6 @@ public String toString() { */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { - private String field; - - /** - * Required - The target field - */ - public final Builder field(String value) { - this.field = value; - return this; - } - private String fullName; private Map mapping; @@ -217,8 +192,6 @@ protected static void setupFieldMappingDeserializer(ObjectDeserializer 1) { hash = hash.substring(1); } - window.location = "https://github.com/elastic/elasticsearch-specification/tree/d4e6f15987391750eafc747b997b776e70bc85a7/specification/" + (paths[hash] || ""); + window.location = "https://github.com/elastic/elasticsearch-specification/tree/cda51c1e6118ea3ba2bb973b77fbf5dc32badebc/specification/" + (paths[hash] || ""); - Please see the Elasticsearch API specification. + Please see the Elasticsearch API specification. diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/IndexSettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/IndexSettings.java index 157affdbc..2d4841a6c 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/IndexSettings.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/IndexSettings.java @@ -24,6 +24,7 @@ package co.elastic.clients.elasticsearch.indices; import co.elastic.clients.elasticsearch._types.Time; +import co.elastic.clients.json.JsonData; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; @@ -38,7 +39,9 @@ import java.lang.Boolean; import java.lang.Integer; import java.lang.String; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.function.Function; import javax.annotation.Nullable; @@ -55,6 +58,8 @@ */ @JsonpDeserializable public class IndexSettings implements JsonpSerializable { + private final Map otherSettings; + @Nullable private final IndexSettings index; @@ -220,7 +225,7 @@ public class IndexSettings implements JsonpSerializable { private final IndexSettings settings; @Nullable - private final MappingLimitSettings mappings; + private final MappingLimitSettings mapping; @Nullable private final SlowlogSettings indexingSlowlog; @@ -235,6 +240,8 @@ public class IndexSettings implements JsonpSerializable { private IndexSettings(Builder builder) { + this.otherSettings = ApiTypeHelper.unmodifiable(builder.otherSettings); + this.index = builder.index; this.mode = builder.mode; this.routingPath = ApiTypeHelper.unmodifiable(builder.routingPath); @@ -290,7 +297,7 @@ private IndexSettings(Builder builder) { this.topMetricsMaxSize = builder.topMetricsMaxSize; this.analysis = builder.analysis; this.settings = builder.settings; - this.mappings = builder.mappings; + this.mapping = builder.mapping; this.indexingSlowlog = builder.indexingSlowlog; this.indexingPressure = builder.indexingPressure; this.store = builder.store; @@ -301,6 +308,16 @@ public static IndexSettings of(Function> f return fn.apply(new Builder()).build(); } + /** + * Additional settings not covered in this type. Unless these settings are + * defined by a plugin, please open an issue on the Elasticsearch API + * specification so that they can be added in a future release. + */ + public final Map otherSettings() { + return this.otherSettings; + } + /** * API name: {@code index} */ @@ -743,11 +760,11 @@ public final IndexSettings settings() { /** * Enable or disable dynamic mapping for an index. *

- * API name: {@code mappings} + * API name: {@code mapping} */ @Nullable - public final MappingLimitSettings mappings() { - return this.mappings; + public final MappingLimitSettings mapping() { + return this.mapping; } /** @@ -790,6 +807,12 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + for (Map.Entry item0 : this.otherSettings.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + if (this.index != null) { generator.writeKey("index"); this.index.serialize(generator, mapper); @@ -1069,9 +1092,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { this.settings.serialize(generator, mapper); } - if (this.mappings != null) { - generator.writeKey("mappings"); - this.mappings.serialize(generator, mapper); + if (this.mapping != null) { + generator.writeKey("mapping"); + this.mapping.serialize(generator, mapper); } if (this.indexingSlowlog != null) { @@ -1104,6 +1127,35 @@ public String toString() { */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + @Nullable + private Map otherSettings = new HashMap<>(); + + /** + * Additional settings not covered in this type. Unless these settings are + * defined by a plugin, please open an issue on the Elasticsearch API + * specification so that they can be added in a future release. + *

+ * Adds all entries of map to otherSettings. + */ + public final Builder otherSettings(Map map) { + this.otherSettings = _mapPutAll(this.otherSettings, map); + return this; + } + + /** + * Additional settings not covered in this type. Unless these settings are + * defined by a plugin, please open an issue on the Elasticsearch API + * specification so that they can be added in a future release. + *

+ * Adds an entry to otherSettings. + */ + public final Builder otherSettings(String key, JsonData value) { + this.otherSettings = _mapPut(this.otherSettings, key, value); + return this; + } + @Nullable private IndexSettings index; @@ -1270,7 +1322,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement private IndexSettings settings; @Nullable - private MappingLimitSettings mappings; + private MappingLimitSettings mapping; @Nullable private SlowlogSettings indexingSlowlog; @@ -1836,20 +1888,20 @@ public final Builder settings(Function - * API name: {@code mappings} + * API name: {@code mapping} */ - public final Builder mappings(@Nullable MappingLimitSettings value) { - this.mappings = value; + public final Builder mapping(@Nullable MappingLimitSettings value) { + this.mapping = value; return this; } /** * Enable or disable dynamic mapping for an index. *

- * API name: {@code mappings} + * API name: {@code mapping} */ - public final Builder mappings(Function> fn) { - return this.mappings(fn.apply(new MappingLimitSettings.Builder()).build()); + public final Builder mapping(Function> fn) { + return this.mapping(fn.apply(new MappingLimitSettings.Builder()).build()); } /** @@ -2021,11 +2073,15 @@ protected static void setupIndexSettingsDeserializer(ObjectDeserializer { + builder.otherSettings(name, JsonData._DESERIALIZER.deserialize(parser, mapper)); + }); + } } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/get_field_mapping/TypeFieldMappings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/get_field_mapping/TypeFieldMappings.java index daa565905..95dadf988 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/get_field_mapping/TypeFieldMappings.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/get_field_mapping/TypeFieldMappings.java @@ -35,6 +35,8 @@ import co.elastic.clients.util.ObjectBuilder; import co.elastic.clients.util.WithJsonObjectBuilderBase; import jakarta.json.stream.JsonGenerator; +import java.lang.String; +import java.util.Map; import java.util.Objects; import java.util.function.Function; import javax.annotation.Nullable; @@ -49,13 +51,13 @@ */ @JsonpDeserializable public class TypeFieldMappings implements JsonpSerializable { - private final FieldMapping mappings; + private final Map mappings; // --------------------------------------------------------------------------------------------- private TypeFieldMappings(Builder builder) { - this.mappings = ApiTypeHelper.requireNonNull(builder.mappings, this, "mappings"); + this.mappings = ApiTypeHelper.unmodifiableRequired(builder.mappings, this, "mappings"); } @@ -66,7 +68,7 @@ public static TypeFieldMappings of(Function mappings() { return this.mappings; } @@ -81,8 +83,17 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("mappings"); - this.mappings.serialize(generator, mapper); + if (ApiTypeHelper.isDefined(this.mappings)) { + generator.writeKey("mappings"); + generator.writeStartObject(); + for (Map.Entry item0 : this.mappings.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + + } } @@ -98,21 +109,35 @@ public String toString() { */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { - private FieldMapping mappings; + private Map mappings; + + /** + * Required - API name: {@code mappings} + *

+ * Adds all entries of map to mappings. + */ + public final Builder mappings(Map map) { + this.mappings = _mapPutAll(this.mappings, map); + return this; + } /** * Required - API name: {@code mappings} + *

+ * Adds an entry to mappings. */ - public final Builder mappings(FieldMapping value) { - this.mappings = value; + public final Builder mappings(String key, FieldMapping value) { + this.mappings = _mapPut(this.mappings, key, value); return this; } /** * Required - API name: {@code mappings} + *

+ * Adds an entry to mappings using a builder lambda. */ - public final Builder mappings(Function> fn) { - return this.mappings(fn.apply(new FieldMapping.Builder()).build()); + public final Builder mappings(String key, Function> fn) { + return mappings(key, fn.apply(new FieldMapping.Builder()).build()); } @Override @@ -143,7 +168,7 @@ public TypeFieldMappings build() { protected static void setupTypeFieldMappingsDeserializer(ObjectDeserializer op) { - op.add(Builder::mappings, FieldMapping._DESERIALIZER, "mappings"); + op.add(Builder::mappings, JsonpDeserializer.stringMapDeserializer(FieldMapping._DESERIALIZER), "mappings"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/recovery/ShardRecovery.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/recovery/ShardRecovery.java index 073b94a19..d336a2182 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/recovery/ShardRecovery.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/recovery/ShardRecovery.java @@ -72,6 +72,7 @@ public class ShardRecovery implements JsonpSerializable { @Nullable private final String stopTime; + @Nullable private final String stopTimeInMillis; private final RecoveryOrigin target; @@ -100,7 +101,7 @@ private ShardRecovery(Builder builder) { this.startTime = builder.startTime; this.startTimeInMillis = ApiTypeHelper.requireNonNull(builder.startTimeInMillis, this, "startTimeInMillis"); this.stopTime = builder.stopTime; - this.stopTimeInMillis = ApiTypeHelper.requireNonNull(builder.stopTimeInMillis, this, "stopTimeInMillis"); + this.stopTimeInMillis = builder.stopTimeInMillis; this.target = ApiTypeHelper.requireNonNull(builder.target, this, "target"); this.totalTime = builder.totalTime; this.totalTimeInMillis = ApiTypeHelper.requireNonNull(builder.totalTimeInMillis, this, "totalTimeInMillis"); @@ -181,8 +182,9 @@ public final String stopTime() { } /** - * Required - API name: {@code stop_time_in_millis} + * API name: {@code stop_time_in_millis} */ + @Nullable public final String stopTimeInMillis() { return this.stopTimeInMillis; } @@ -274,9 +276,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write(this.stopTime); } - generator.writeKey("stop_time_in_millis"); - generator.write(this.stopTimeInMillis); + if (this.stopTimeInMillis != null) { + generator.writeKey("stop_time_in_millis"); + generator.write(this.stopTimeInMillis); + } generator.writeKey("target"); this.target.serialize(generator, mapper); @@ -332,6 +336,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement @Nullable private String stopTime; + @Nullable private String stopTimeInMillis; private RecoveryOrigin target; @@ -441,9 +446,9 @@ public final Builder stopTime(@Nullable String value) { } /** - * Required - API name: {@code stop_time_in_millis} + * API name: {@code stop_time_in_millis} */ - public final Builder stopTimeInMillis(String value) { + public final Builder stopTimeInMillis(@Nullable String value) { this.stopTimeInMillis = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/sql/TranslateResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/sql/TranslateResponse.java index 703d48943..c88c8bbf2 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/sql/TranslateResponse.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/sql/TranslateResponse.java @@ -24,6 +24,9 @@ package co.elastic.clients.elasticsearch.sql; import co.elastic.clients.elasticsearch._types.SortOptions; +import co.elastic.clients.elasticsearch._types.aggregations.Aggregation; +import co.elastic.clients.elasticsearch._types.query_dsl.FieldAndFormat; +import co.elastic.clients.elasticsearch._types.query_dsl.Query; import co.elastic.clients.elasticsearch.core.search.SourceConfig; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; @@ -53,11 +56,18 @@ */ @JsonpDeserializable public class TranslateResponse implements JsonpSerializable { - private final long size; + private final Map aggregations; + @Nullable + private final Long size; + + @Nullable private final SourceConfig source; - private final List> fields; + private final List fields; + + @Nullable + private final Query query; private final List sort; @@ -65,10 +75,12 @@ public class TranslateResponse implements JsonpSerializable { private TranslateResponse(Builder builder) { - this.size = ApiTypeHelper.requireNonNull(builder.size, this, "size"); - this.source = ApiTypeHelper.requireNonNull(builder.source, this, "source"); - this.fields = ApiTypeHelper.unmodifiableRequired(builder.fields, this, "fields"); - this.sort = ApiTypeHelper.unmodifiableRequired(builder.sort, this, "sort"); + this.aggregations = ApiTypeHelper.unmodifiable(builder.aggregations); + this.size = builder.size; + this.source = builder.source; + this.fields = ApiTypeHelper.unmodifiable(builder.fields); + this.query = builder.query; + this.sort = ApiTypeHelper.unmodifiable(builder.sort); } @@ -77,28 +89,45 @@ public static TranslateResponse of(Function aggregations() { + return this.aggregations; + } + + /** + * API name: {@code size} + */ + @Nullable + public final Long size() { return this.size; } /** - * Required - API name: {@code _source} + * API name: {@code _source} */ + @Nullable public final SourceConfig source() { return this.source; } /** - * Required - API name: {@code fields} + * API name: {@code fields} */ - public final List> fields() { + public final List fields() { return this.fields; } /** - * Required - API name: {@code sort} + * API name: {@code query} + */ + @Nullable + public final Query query() { + return this.query; + } + + /** + * API name: {@code sort} */ public final List sort() { return this.sort; @@ -115,29 +144,41 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - generator.writeKey("size"); - generator.write(this.size); + if (ApiTypeHelper.isDefined(this.aggregations)) { + generator.writeKey("aggregations"); + generator.writeStartObject(); + for (Map.Entry item0 : this.aggregations.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); - generator.writeKey("_source"); - this.source.serialize(generator, mapper); + } + generator.writeEnd(); + + } + if (this.size != null) { + generator.writeKey("size"); + generator.write(this.size); + } + if (this.source != null) { + generator.writeKey("_source"); + this.source.serialize(generator, mapper); + + } if (ApiTypeHelper.isDefined(this.fields)) { generator.writeKey("fields"); generator.writeStartArray(); - for (Map item0 : this.fields) { - generator.writeStartObject(); - if (item0 != null) { - for (Map.Entry item1 : item0.entrySet()) { - generator.writeKey(item1.getKey()); - generator.write(item1.getValue()); - - } - } - generator.writeEnd(); + for (FieldAndFormat item0 : this.fields) { + item0.serialize(generator, mapper); } generator.writeEnd(); + } + if (this.query != null) { + generator.writeKey("query"); + this.query.serialize(generator, mapper); + } if (ApiTypeHelper.isDefined(this.sort)) { generator.writeKey("sort"); @@ -164,59 +205,122 @@ public String toString() { */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + @Nullable + private Map aggregations; + + @Nullable private Long size; + @Nullable private SourceConfig source; - private List> fields; + @Nullable + private List fields; + + @Nullable + private Query query; + @Nullable private List sort; /** - * Required - API name: {@code size} + * API name: {@code aggregations} + *

+ * Adds all entries of map to aggregations. + */ + public final Builder aggregations(Map map) { + this.aggregations = _mapPutAll(this.aggregations, map); + return this; + } + + /** + * API name: {@code aggregations} + *

+ * Adds an entry to aggregations. + */ + public final Builder aggregations(String key, Aggregation value) { + this.aggregations = _mapPut(this.aggregations, key, value); + return this; + } + + /** + * API name: {@code aggregations} + *

+ * Adds an entry to aggregations using a builder lambda. */ - public final Builder size(long value) { + public final Builder aggregations(String key, Function> fn) { + return aggregations(key, fn.apply(new Aggregation.Builder()).build()); + } + + /** + * API name: {@code size} + */ + public final Builder size(@Nullable Long value) { this.size = value; return this; } /** - * Required - API name: {@code _source} + * API name: {@code _source} */ - public final Builder source(SourceConfig value) { + public final Builder source(@Nullable SourceConfig value) { this.source = value; return this; } /** - * Required - API name: {@code _source} + * API name: {@code _source} */ public final Builder source(Function> fn) { return this.source(fn.apply(new SourceConfig.Builder()).build()); } /** - * Required - API name: {@code fields} + * API name: {@code fields} *

* Adds all elements of list to fields. */ - public final Builder fields(List> list) { + public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** - * Required - API name: {@code fields} + * API name: {@code fields} *

* Adds one or more values to fields. */ - public final Builder fields(Map value, Map... values) { + public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** - * Required - API name: {@code sort} + * API name: {@code fields} + *

+ * Adds a value to fields using a builder lambda. + */ + public final Builder fields(Function> fn) { + return fields(fn.apply(new FieldAndFormat.Builder()).build()); + } + + /** + * API name: {@code query} + */ + public final Builder query(@Nullable Query value) { + this.query = value; + return this; + } + + /** + * API name: {@code query} + */ + public final Builder query(Function> fn) { + return this.query(fn.apply(new Query.Builder()).build()); + } + + /** + * API name: {@code sort} *

* Adds all elements of list to sort. */ @@ -226,7 +330,7 @@ public final Builder sort(List list) { } /** - * Required - API name: {@code sort} + * API name: {@code sort} *

* Adds one or more values to sort. */ @@ -236,7 +340,7 @@ public final Builder sort(SortOptions value, SortOptions... values) { } /** - * Required - API name: {@code sort} + * API name: {@code sort} *

* Adds a value to sort using a builder lambda. */ @@ -272,10 +376,12 @@ public TranslateResponse build() { protected static void setupTranslateResponseDeserializer(ObjectDeserializer op) { + op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), + "aggregations"); op.add(Builder::size, JsonpDeserializer.longDeserializer(), "size"); op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); - op.add(Builder::fields, JsonpDeserializer.arrayDeserializer( - JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer())), "fields"); + op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); + op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); } diff --git a/java-client/src/main/java/co/elastic/clients/util/NamedValue.java b/java-client/src/main/java/co/elastic/clients/util/NamedValue.java new file mode 100644 index 000000000..654ff8d02 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/util/NamedValue.java @@ -0,0 +1,73 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package co.elastic.clients.util; + +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpDeserializerBase; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.JsonpMappingException; +import co.elastic.clients.json.JsonpUtils; +import jakarta.json.stream.JsonParser; + +import java.util.EnumSet; +import java.util.function.Supplier; + +public class NamedValue { + + private final String name; + private final T value; + + public NamedValue(String name, T value) { + this.name = name; + this.value = value; + } + + public String name() { + return this.name; + } + + public T value() { + return this.value; + } + + public static NamedValue of(String name, T value) { + return new NamedValue<>(name, value); + } + + public static JsonpDeserializer> deserializer(Supplier> valueParserBuilder) { + return new JsonpDeserializerBase>(EnumSet.of(JsonParser.Event.START_OBJECT)) { + @Override + public NamedValue deserialize(JsonParser parser, JsonpMapper mapper, JsonParser.Event event) { + + JsonpUtils.expectNextEvent(parser, JsonParser.Event.KEY_NAME); + String name = parser.getString(); + + try { + T value = valueParserBuilder.get().deserialize(parser, mapper); + JsonpUtils.expectNextEvent(parser, JsonParser.Event.END_OBJECT); + + return new NamedValue<>(name, value); + } catch (Exception e) { + throw JsonpMappingException.from(e, null, name, parser); + } + } + }; + } +} diff --git a/java-client/src/test/java/co/elastic/clients/elasticsearch/ElasticsearchTestServer.java b/java-client/src/test/java/co/elastic/clients/elasticsearch/ElasticsearchTestServer.java index 207d10814..7ae2ea10e 100644 --- a/java-client/src/test/java/co/elastic/clients/elasticsearch/ElasticsearchTestServer.java +++ b/java-client/src/test/java/co/elastic/clients/elasticsearch/ElasticsearchTestServer.java @@ -19,9 +19,14 @@ package co.elastic.clients.elasticsearch; +import co.elastic.clients.elasticsearch._types.ErrorResponse; +import co.elastic.clients.json.JsonData; +import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; import co.elastic.clients.json.jsonb.JsonbJsonpMapper; import co.elastic.clients.transport.ElasticsearchTransport; +import co.elastic.clients.transport.JsonEndpoint; +import co.elastic.clients.transport.endpoints.DelegatingJsonEndpoint; import co.elastic.clients.transport.rest_client.RestClientTransport; import org.apache.http.HttpHost; import org.apache.http.auth.AuthScope; @@ -30,6 +35,7 @@ import org.elasticsearch.client.RestClient; import org.testcontainers.elasticsearch.ElasticsearchContainer; +import java.io.IOException; import java.time.Duration; public class ElasticsearchTestServer implements AutoCloseable { @@ -81,6 +87,33 @@ AuthScope.ANY, new UsernamePasswordCredentials("elastic", "changeme") client = new ElasticsearchClient(transport); } + /** + * Send a request to a server and return the response as JSON. Useful to debug response format issues. + */ + public static JsonData getJsonResponse(ElasticsearchClient client, Req request) throws IOException { + + JsonEndpoint endpoint; + + try { + @SuppressWarnings("unchecked") + JsonEndpoint endpoint0 = (JsonEndpoint) request.getClass() + .getDeclaredField("_ENDPOINT").get(null); + endpoint = endpoint0; + } catch (IllegalAccessException|NoSuchFieldException e) { + throw new RuntimeException(e); + } + + DelegatingJsonEndpoint jsonEndpoint = + new DelegatingJsonEndpoint(endpoint) { + @Override + public JsonpDeserializer responseDeserializer() { + return JsonData._DESERIALIZER; + } + }; + + return client._transport().performRequest(request, jsonEndpoint, client._transportOptions()); + } + @Override public void close() { if (this == global) { diff --git a/java-client/src/test/java/co/elastic/clients/elasticsearch/model/BehaviorsTest.java b/java-client/src/test/java/co/elastic/clients/elasticsearch/model/BehaviorsTest.java index a23d387bc..692302077 100644 --- a/java-client/src/test/java/co/elastic/clients/elasticsearch/model/BehaviorsTest.java +++ b/java-client/src/test/java/co/elastic/clients/elasticsearch/model/BehaviorsTest.java @@ -35,6 +35,9 @@ public class BehaviorsTest extends ModelTestCase { + /** + * Test for SingleKeyDictionary transformed to a behavior. For regular fields, see NamedValue tests in {@link ClassStructureTest} + */ @Test public void testSingleKeyDictionary() { TermQuery q = new TermQuery.Builder() diff --git a/java-client/src/test/java/co/elastic/clients/elasticsearch/model/ClassStructureTest.java b/java-client/src/test/java/co/elastic/clients/elasticsearch/model/ClassStructureTest.java index 68e8f899c..ad69f8756 100644 --- a/java-client/src/test/java/co/elastic/clients/elasticsearch/model/ClassStructureTest.java +++ b/java-client/src/test/java/co/elastic/clients/elasticsearch/model/ClassStructureTest.java @@ -20,12 +20,14 @@ package co.elastic.clients.elasticsearch.model; import co.elastic.clients.elasticsearch._types.ErrorCause; +import co.elastic.clients.elasticsearch._types.SortOrder; import co.elastic.clients.elasticsearch._types.aggregations.Aggregate; import co.elastic.clients.elasticsearch._types.aggregations.Aggregation; import co.elastic.clients.elasticsearch._types.aggregations.Buckets; import co.elastic.clients.elasticsearch._types.aggregations.CardinalityAggregate; import co.elastic.clients.elasticsearch._types.aggregations.DateRangeAggregate; import co.elastic.clients.elasticsearch._types.aggregations.RangeBucket; +import co.elastic.clients.elasticsearch._types.aggregations.TermsAggregation; import co.elastic.clients.elasticsearch._types.aggregations.ValueCountAggregation; import co.elastic.clients.elasticsearch._types.query_dsl.FieldAndFormat; import co.elastic.clients.elasticsearch._types.query_dsl.IntervalsQuery; @@ -37,6 +39,7 @@ import co.elastic.clients.json.JsonData; import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.MissingRequiredPropertyException; +import co.elastic.clients.util.NamedValue; import co.elastic.clients.util.ObjectBuilder; import org.junit.jupiter.api.Test; @@ -319,6 +322,19 @@ public void testRequiredProperty() { assertEquals("id", ex.getPropertyName()); } + /** + * Tests SingleKeyDictionary fields that are not transformed into a behavior. + */ + @Test + public void testNamedValue() { + TermsAggregation termsAgg = TermsAggregation.of(ta -> ta + .order(NamedValue.of("a", SortOrder.Asc)) + .order(NamedValue.of("b", SortOrder.Desc)) + ); + + checkJsonRoundtrip(termsAgg, "{\"order\":[{\"a\":\"asc\"},{\"b\":\"desc\"}]}"); + } + private void assertAncestorCount(int count, Object obj) { Class clazz = obj.getClass(); while(count-- >= 0) { diff --git a/java-client/src/test/java/co/elastic/clients/elasticsearch/spec_issues/SpecIssuesTest.java b/java-client/src/test/java/co/elastic/clients/elasticsearch/spec_issues/SpecIssuesTest.java index 6b9826b35..ab9b94c35 100644 --- a/java-client/src/test/java/co/elastic/clients/elasticsearch/spec_issues/SpecIssuesTest.java +++ b/java-client/src/test/java/co/elastic/clients/elasticsearch/spec_issues/SpecIssuesTest.java @@ -22,18 +22,23 @@ import co.elastic.clients.elasticsearch.ElasticsearchClient; import co.elastic.clients.elasticsearch.ElasticsearchTestServer; import co.elastic.clients.elasticsearch._types.ErrorResponse; +import co.elastic.clients.elasticsearch._types.analysis.LimitTokenCountTokenFilter; import co.elastic.clients.elasticsearch.cluster.ClusterStatsResponse; import co.elastic.clients.elasticsearch.core.SearchRequest; import co.elastic.clients.elasticsearch.core.SearchResponse; +import co.elastic.clients.elasticsearch.indices.CreateIndexRequest; import co.elastic.clients.elasticsearch.indices.GetFieldMappingRequest; import co.elastic.clients.elasticsearch.indices.GetFieldMappingResponse; import co.elastic.clients.elasticsearch.model.ModelTestCase; +import co.elastic.clients.elasticsearch.snapshot.RestoreResponse; import co.elastic.clients.json.JsonData; import co.elastic.clients.json.JsonpDeserializer; import jakarta.json.stream.JsonParser; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.io.InputStream; +import java.io.StringReader; /** * Test issues related to the API specifications. @@ -42,15 +47,89 @@ */ public class SpecIssuesTest extends ModelTestCase { + @Disabled("Not fixed yet") @Test - public void i066_multiFieldMapping() throws Exception { + public void i0201_restoreResponse() throws Exception { + RestoreResponse restoreResponse = fromJson("{\"acknowledged\":true}", RestoreResponse.class); + } + + @Test + public void i0297_mappingSettings() { + + CreateIndexRequest request = CreateIndexRequest.of(r -> r + .index("name") + .settings(s -> s + // This is "mapping" and not "mappings" + .mapping(m -> m.totalFields(totalFields -> totalFields.limit(1001))) + .otherSettings("foo", JsonData.of("bar")) + ) + ); + + assertEquals("{\"settings\":{\"foo\":\"bar\",\"mapping\":{\"total_fields\":{\"limit\":1001}}}}", toJson(request)); + } + + @Test + public void i0295_mappingSettings() { + String json = "{\n" + + " \"mappings\": {\n" + + " \"properties\": {\n" + + " \"myfield\": {\n" + + " \"type\": \"text\"\n" + + " }\n" + + " }\n" + + " },\n" + + " \"settings\": {\n" + + " \"index\": {\n" + + " \"max_result_window\": 1000000,\n" + + " \"mapping\": {\n" + + " \"nested_objects\": {\n" + + " \"limit\": 10000\n" + + " }\n" + + " },\n" + + " \"requests\": {\n" + + " \"cache\": {\n" + + " \"enable\": true\n" + + " }\n" + + " }\n" + + " }\n" + + " }\n" + + "}"; + + CreateIndexRequest request = CreateIndexRequest.of(r -> r + .index("name") + .withJson(new StringReader(json)) + ); + } + + @Test + public void i0199_consumeAllTokensOptional() { + // https://github.com/elastic/elasticsearch-java/issues/199 + // Most filter properties are optional + LimitTokenCountTokenFilter filter = LimitTokenCountTokenFilter.of(b -> b); + } + + @Test + public void i0166_multiFieldMapping() throws Exception { + // https://github.com/elastic/elasticsearch-java/issues/166 ElasticsearchClient client = ElasticsearchTestServer.global().client(); - GetFieldMappingRequest gfmRequest = new GetFieldMappingRequest.Builder() - .index("*") - .fields("*") - .build(); + String indexName = "i0166_multi_field_mapping"; + + client.index(r -> r + .index(indexName) + .withJson(new StringReader("{\"a\":1,\"b\":2}")) + ); + + GetFieldMappingRequest gfmRequest = GetFieldMappingRequest.of (b -> b + .index(indexName) + .fields("a", "b") + ); + GetFieldMappingResponse gfmResponse = client.indices().getFieldMapping(gfmRequest); + + assertEquals(2, gfmResponse.get(indexName).mappings().size()); + assertEquals("a", gfmResponse.get(indexName).mappings().get("a").fullName()); + assertEquals("b", gfmResponse.get(indexName).mappings().get("b").fullName()); } @Test