diff --git a/java-client/build.gradle.kts b/java-client/build.gradle.kts index 581475ae4..d9e208c0f 100644 --- a/java-client/build.gradle.kts +++ b/java-client/build.gradle.kts @@ -225,8 +225,8 @@ dependencies { // MIT // https://www.testcontainers.org/ - testImplementation("org.testcontainers", "testcontainers", "1.17.2") - testImplementation("org.testcontainers", "elasticsearch", "1.17.2") + testImplementation("org.testcontainers", "testcontainers", "1.17.3") + testImplementation("org.testcontainers", "elasticsearch", "1.17.3") } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/ErrorCause.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/ErrorCause.java index 18f10b4c7..1dbe92c22 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/ErrorCause.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/ErrorCause.java @@ -60,6 +60,7 @@ public class ErrorCause implements JsonpSerializable { @Nullable private final String type; + @Nullable private final String reason; @Nullable @@ -79,7 +80,7 @@ private ErrorCause(Builder builder) { this.metadata = ApiTypeHelper.unmodifiable(builder.metadata); this.type = builder.type; - this.reason = ApiTypeHelper.requireNonNull(builder.reason, this, "reason"); + this.reason = builder.reason; this.stackTrace = builder.stackTrace; this.causedBy = builder.causedBy; this.rootCause = ApiTypeHelper.unmodifiable(builder.rootCause); @@ -109,10 +110,11 @@ public final String type() { } /** - * Required - A human-readable explanation of the error, in english + * A human-readable explanation of the error, in english *

* API name: {@code reason} */ + @Nullable public final String reason() { return this.reason; } @@ -172,9 +174,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write(this.type); } - generator.writeKey("reason"); - generator.write(this.reason); + if (this.reason != null) { + generator.writeKey("reason"); + generator.write(this.reason); + } if (this.stackTrace != null) { generator.writeKey("stack_trace"); generator.write(this.stackTrace); @@ -246,6 +250,7 @@ public final Builder metadata(String key, JsonData value) { @Nullable private String type; + @Nullable private String reason; @Nullable @@ -271,11 +276,11 @@ public final Builder type(@Nullable String value) { } /** - * Required - A human-readable explanation of the error, in english + * A human-readable explanation of the error, in english *

* API name: {@code reason} */ - public final Builder reason(String value) { + public final Builder reason(@Nullable String value) { this.reason = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/GeoBoundsAggregate.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/GeoBoundsAggregate.java index 13b853d76..b19f7c5bc 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/GeoBoundsAggregate.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/GeoBoundsAggregate.java @@ -29,7 +29,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.util.Objects; @@ -46,6 +45,7 @@ */ @JsonpDeserializable public class GeoBoundsAggregate extends AggregateBase implements AggregateVariant { + @Nullable private final GeoBounds bounds; // --------------------------------------------------------------------------------------------- @@ -53,7 +53,7 @@ public class GeoBoundsAggregate extends AggregateBase implements AggregateVarian private GeoBoundsAggregate(Builder builder) { super(builder); - this.bounds = ApiTypeHelper.requireNonNull(builder.bounds, this, "bounds"); + this.bounds = builder.bounds; } @@ -70,8 +70,9 @@ public Aggregate.Kind _aggregateKind() { } /** - * Required - API name: {@code bounds} + * API name: {@code bounds} */ + @Nullable public final GeoBounds bounds() { return this.bounds; } @@ -79,8 +80,11 @@ public final GeoBounds bounds() { protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { super.serializeInternal(generator, mapper); - generator.writeKey("bounds"); - this.bounds.serialize(generator, mapper); + if (this.bounds != null) { + generator.writeKey("bounds"); + this.bounds.serialize(generator, mapper); + + } } @@ -93,18 +97,19 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends AggregateBase.AbstractBuilder implements ObjectBuilder { + @Nullable private GeoBounds bounds; /** - * Required - API name: {@code bounds} + * API name: {@code bounds} */ - public final Builder bounds(GeoBounds value) { + public final Builder bounds(@Nullable GeoBounds value) { this.bounds = value; return this; } /** - * Required - API name: {@code bounds} + * API name: {@code bounds} */ public final Builder bounds(Function> fn) { return this.bounds(fn.apply(new GeoBounds.Builder()).build()); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/IcuCollationTokenFilter.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/IcuCollationTokenFilter.java index 187d5a54e..a11cf5f5a 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/IcuCollationTokenFilter.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/IcuCollationTokenFilter.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,27 +46,40 @@ */ @JsonpDeserializable public class IcuCollationTokenFilter extends TokenFilterBase implements TokenFilterDefinitionVariant { + @Nullable private final IcuCollationAlternate alternate; + @Nullable private final IcuCollationCaseFirst casefirst; - private final boolean caselevel; + @Nullable + private final Boolean caselevel; + @Nullable private final String country; + @Nullable private final IcuCollationDecomposition decomposition; - private final boolean hiraganaquaternarymode; + @Nullable + private final Boolean hiraganaquaternarymode; + @Nullable private final String language; - private final boolean numeric; + @Nullable + private final Boolean numeric; + @Nullable + private final String rules; + + @Nullable private final IcuCollationStrength strength; @Nullable private final String variabletop; + @Nullable private final String variant; // --------------------------------------------------------------------------------------------- @@ -75,18 +87,18 @@ public class IcuCollationTokenFilter extends TokenFilterBase implements TokenFil private IcuCollationTokenFilter(Builder builder) { super(builder); - this.alternate = ApiTypeHelper.requireNonNull(builder.alternate, this, "alternate"); - this.casefirst = ApiTypeHelper.requireNonNull(builder.casefirst, this, "casefirst"); - this.caselevel = ApiTypeHelper.requireNonNull(builder.caselevel, this, "caselevel"); - this.country = ApiTypeHelper.requireNonNull(builder.country, this, "country"); - this.decomposition = ApiTypeHelper.requireNonNull(builder.decomposition, this, "decomposition"); - this.hiraganaquaternarymode = ApiTypeHelper.requireNonNull(builder.hiraganaquaternarymode, this, - "hiraganaquaternarymode"); - this.language = ApiTypeHelper.requireNonNull(builder.language, this, "language"); - this.numeric = ApiTypeHelper.requireNonNull(builder.numeric, this, "numeric"); - this.strength = ApiTypeHelper.requireNonNull(builder.strength, this, "strength"); + this.alternate = builder.alternate; + this.casefirst = builder.casefirst; + this.caselevel = builder.caselevel; + this.country = builder.country; + this.decomposition = builder.decomposition; + this.hiraganaquaternarymode = builder.hiraganaquaternarymode; + this.language = builder.language; + this.numeric = builder.numeric; + this.rules = builder.rules; + this.strength = builder.strength; this.variabletop = builder.variabletop; - this.variant = ApiTypeHelper.requireNonNull(builder.variant, this, "variant"); + this.variant = builder.variant; } @@ -103,64 +115,81 @@ public TokenFilterDefinition.Kind _tokenFilterDefinitionKind() { } /** - * Required - API name: {@code alternate} + * API name: {@code alternate} */ + @Nullable public final IcuCollationAlternate alternate() { return this.alternate; } /** - * Required - API name: {@code caseFirst} + * API name: {@code caseFirst} */ + @Nullable public final IcuCollationCaseFirst casefirst() { return this.casefirst; } /** - * Required - API name: {@code caseLevel} + * API name: {@code caseLevel} */ - public final boolean caselevel() { + @Nullable + public final Boolean caselevel() { return this.caselevel; } /** - * Required - API name: {@code country} + * API name: {@code country} */ + @Nullable public final String country() { return this.country; } /** - * Required - API name: {@code decomposition} + * API name: {@code decomposition} */ + @Nullable public final IcuCollationDecomposition decomposition() { return this.decomposition; } /** - * Required - API name: {@code hiraganaQuaternaryMode} + * API name: {@code hiraganaQuaternaryMode} */ - public final boolean hiraganaquaternarymode() { + @Nullable + public final Boolean hiraganaquaternarymode() { return this.hiraganaquaternarymode; } /** - * Required - API name: {@code language} + * API name: {@code language} */ + @Nullable public final String language() { return this.language; } /** - * Required - API name: {@code numeric} + * API name: {@code numeric} */ - public final boolean numeric() { + @Nullable + public final Boolean numeric() { return this.numeric; } /** - * Required - API name: {@code strength} + * API name: {@code rules} + */ + @Nullable + public final String rules() { + return this.rules; + } + + /** + * API name: {@code strength} */ + @Nullable public final IcuCollationStrength strength() { return this.strength; } @@ -174,8 +203,9 @@ public final String variabletop() { } /** - * Required - API name: {@code variant} + * API name: {@code variant} */ + @Nullable public final String variant() { return this.variant; } @@ -184,36 +214,62 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.write("type", "icu_collation"); super.serializeInternal(generator, mapper); - generator.writeKey("alternate"); - this.alternate.serialize(generator, mapper); - generator.writeKey("caseFirst"); - this.casefirst.serialize(generator, mapper); - generator.writeKey("caseLevel"); - generator.write(this.caselevel); + if (this.alternate != null) { + generator.writeKey("alternate"); + this.alternate.serialize(generator, mapper); + } + if (this.casefirst != null) { + generator.writeKey("caseFirst"); + this.casefirst.serialize(generator, mapper); + } + if (this.caselevel != null) { + generator.writeKey("caseLevel"); + generator.write(this.caselevel); - generator.writeKey("country"); - generator.write(this.country); + } + if (this.country != null) { + generator.writeKey("country"); + generator.write(this.country); - generator.writeKey("decomposition"); - this.decomposition.serialize(generator, mapper); - generator.writeKey("hiraganaQuaternaryMode"); - generator.write(this.hiraganaquaternarymode); + } + if (this.decomposition != null) { + generator.writeKey("decomposition"); + this.decomposition.serialize(generator, mapper); + } + if (this.hiraganaquaternarymode != null) { + generator.writeKey("hiraganaQuaternaryMode"); + generator.write(this.hiraganaquaternarymode); - generator.writeKey("language"); - generator.write(this.language); + } + if (this.language != null) { + generator.writeKey("language"); + generator.write(this.language); - generator.writeKey("numeric"); - generator.write(this.numeric); + } + if (this.numeric != null) { + generator.writeKey("numeric"); + generator.write(this.numeric); + + } + if (this.rules != null) { + generator.writeKey("rules"); + generator.write(this.rules); - generator.writeKey("strength"); - this.strength.serialize(generator, mapper); + } + if (this.strength != null) { + generator.writeKey("strength"); + this.strength.serialize(generator, mapper); + } if (this.variabletop != null) { generator.writeKey("variableTop"); generator.write(this.variabletop); } - generator.writeKey("variant"); - generator.write(this.variant); + if (this.variant != null) { + generator.writeKey("variant"); + generator.write(this.variant); + + } } @@ -226,97 +282,118 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends TokenFilterBase.AbstractBuilder implements ObjectBuilder { + @Nullable private IcuCollationAlternate alternate; + @Nullable private IcuCollationCaseFirst casefirst; + @Nullable private Boolean caselevel; + @Nullable private String country; + @Nullable private IcuCollationDecomposition decomposition; + @Nullable private Boolean hiraganaquaternarymode; + @Nullable private String language; + @Nullable private Boolean numeric; + @Nullable + private String rules; + + @Nullable private IcuCollationStrength strength; @Nullable private String variabletop; + @Nullable private String variant; /** - * Required - API name: {@code alternate} + * API name: {@code alternate} */ - public final Builder alternate(IcuCollationAlternate value) { + public final Builder alternate(@Nullable IcuCollationAlternate value) { this.alternate = value; return this; } /** - * Required - API name: {@code caseFirst} + * API name: {@code caseFirst} */ - public final Builder casefirst(IcuCollationCaseFirst value) { + public final Builder casefirst(@Nullable IcuCollationCaseFirst value) { this.casefirst = value; return this; } /** - * Required - API name: {@code caseLevel} + * API name: {@code caseLevel} */ - public final Builder caselevel(boolean value) { + public final Builder caselevel(@Nullable Boolean value) { this.caselevel = value; return this; } /** - * Required - API name: {@code country} + * API name: {@code country} */ - public final Builder country(String value) { + public final Builder country(@Nullable String value) { this.country = value; return this; } /** - * Required - API name: {@code decomposition} + * API name: {@code decomposition} */ - public final Builder decomposition(IcuCollationDecomposition value) { + public final Builder decomposition(@Nullable IcuCollationDecomposition value) { this.decomposition = value; return this; } /** - * Required - API name: {@code hiraganaQuaternaryMode} + * API name: {@code hiraganaQuaternaryMode} */ - public final Builder hiraganaquaternarymode(boolean value) { + public final Builder hiraganaquaternarymode(@Nullable Boolean value) { this.hiraganaquaternarymode = value; return this; } /** - * Required - API name: {@code language} + * API name: {@code language} */ - public final Builder language(String value) { + public final Builder language(@Nullable String value) { this.language = value; return this; } /** - * Required - API name: {@code numeric} + * API name: {@code numeric} */ - public final Builder numeric(boolean value) { + public final Builder numeric(@Nullable Boolean value) { this.numeric = value; return this; } /** - * Required - API name: {@code strength} + * API name: {@code rules} + */ + public final Builder rules(@Nullable String value) { + this.rules = value; + return this; + } + + /** + * API name: {@code strength} */ - public final Builder strength(IcuCollationStrength value) { + public final Builder strength(@Nullable IcuCollationStrength value) { this.strength = value; return this; } @@ -330,9 +407,9 @@ public final Builder variabletop(@Nullable String value) { } /** - * Required - API name: {@code variant} + * API name: {@code variant} */ - public final Builder variant(String value) { + public final Builder variant(@Nullable String value) { this.variant = value; return this; } @@ -374,6 +451,7 @@ protected static void setupIcuCollationTokenFilterDeserializer( op.add(Builder::hiraganaquaternarymode, JsonpDeserializer.booleanDeserializer(), "hiraganaQuaternaryMode"); op.add(Builder::language, JsonpDeserializer.stringDeserializer(), "language"); op.add(Builder::numeric, JsonpDeserializer.booleanDeserializer(), "numeric"); + op.add(Builder::rules, JsonpDeserializer.stringDeserializer(), "rules"); op.add(Builder::strength, IcuCollationStrength._DESERIALIZER, "strength"); op.add(Builder::variabletop, JsonpDeserializer.stringDeserializer(), "variableTop"); op.add(Builder::variant, JsonpDeserializer.stringDeserializer(), "variant"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/async_search/SubmitRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/async_search/SubmitRequest.java index 4df0463a4..387def1ec 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/async_search/SubmitRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/async_search/SubmitRequest.java @@ -44,6 +44,7 @@ import co.elastic.clients.elasticsearch.core.search.SourceConfig; import co.elastic.clients.elasticsearch.core.search.Suggester; import co.elastic.clients.elasticsearch.core.search.TrackHits; +import co.elastic.clients.json.JsonData; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; @@ -118,6 +119,8 @@ public class SubmitRequest extends RequestBase implements JsonpSerializable { @Nullable private final Boolean explain; + private final Map ext; + private final List fields; @Nullable @@ -186,7 +189,7 @@ public class SubmitRequest extends RequestBase implements JsonpSerializable { @Nullable private final String routing; - private final Map> runtimeMappings; + private final Map runtimeMappings; private final Map scriptFields; @@ -252,6 +255,7 @@ private SubmitRequest(Builder builder) { this.docvalueFields = ApiTypeHelper.unmodifiable(builder.docvalueFields); this.expandWildcards = ApiTypeHelper.unmodifiable(builder.expandWildcards); this.explain = builder.explain; + this.ext = ApiTypeHelper.unmodifiable(builder.ext); this.fields = ApiTypeHelper.unmodifiable(builder.fields); this.from = builder.from; this.highlight = builder.highlight; @@ -443,6 +447,15 @@ public final Boolean explain() { return this.explain; } + /** + * Configuration of search extensions defined by Elasticsearch plugins. + *

+ * API name: {@code ext} + */ + public final Map ext() { + return this.ext; + } + /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. @@ -688,7 +701,7 @@ public final String routing() { *

* API name: {@code runtime_mappings} */ - public final Map> runtimeMappings() { + public final Map runtimeMappings() { return this.runtimeMappings; } @@ -910,6 +923,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("explain"); generator.write(this.explain); + } + if (ApiTypeHelper.isDefined(this.ext)) { + generator.writeKey("ext"); + generator.writeStartObject(); + for (Map.Entry item0 : this.ext.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + } if (ApiTypeHelper.isDefined(this.fields)) { generator.writeKey("fields"); @@ -992,16 +1016,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); - for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { + for (Map.Entry item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); - generator.writeStartArray(); - if (item0.getValue() != null) { - for (RuntimeField item1 : item0.getValue()) { - item1.serialize(generator, mapper); - - } - } - generator.writeEnd(); + item0.getValue().serialize(generator, mapper); } generator.writeEnd(); @@ -1155,6 +1172,9 @@ public static class Builder extends WithJsonObjectBuilderBase implement @Nullable private Boolean explain; + @Nullable + private Map ext; + @Nullable private List fields; @@ -1228,7 +1248,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement private String routing; @Nullable - private Map> runtimeMappings; + private Map runtimeMappings; @Nullable private Map scriptFields; @@ -1506,6 +1526,30 @@ public final Builder explain(@Nullable Boolean value) { return this; } + /** + * Configuration of search extensions defined by Elasticsearch plugins. + *

+ * API name: {@code ext} + *

+ * Adds all entries of map to ext. + */ + public final Builder ext(Map map) { + this.ext = _mapPutAll(this.ext, map); + return this; + } + + /** + * Configuration of search extensions defined by Elasticsearch plugins. + *

+ * API name: {@code ext} + *

+ * Adds an entry to ext. + */ + public final Builder ext(String key, JsonData value) { + this.ext = _mapPut(this.ext, key, value); + return this; + } + /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. @@ -1886,7 +1930,7 @@ public final Builder routing(@Nullable String value) { *

* Adds all entries of map to runtimeMappings. */ - public final Builder runtimeMappings(Map> map) { + public final Builder runtimeMappings(Map map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } @@ -1899,11 +1943,24 @@ public final Builder runtimeMappings(Map> map) { *

* Adds an entry to runtimeMappings. */ - public final Builder runtimeMappings(String key, List value) { + public final Builder runtimeMappings(String key, RuntimeField value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } + /** + * Defines one or more runtime fields in the search request. These fields take + * precedence over mapped fields with the same name. + *

+ * API name: {@code runtime_mappings} + *

+ * Adds an entry to runtimeMappings using a builder lambda. + */ + public final Builder runtimeMappings(String key, + Function> fn) { + return runtimeMappings(key, fn.apply(new RuntimeField.Builder()).build()); + } + /** * Retrieve a script evaluation (based on different fields) for each hit. *

@@ -2249,6 +2306,7 @@ protected static void setupSubmitRequestDeserializer(ObjectDeserializer settings() { return this.settings; @@ -197,6 +197,7 @@ public static class Builder extends WithJsonObjectBuilderBase @Nullable private Long version; + @Nullable private Map settings; @Nullable @@ -234,7 +235,7 @@ public final Builder version(@Nullable Long value) { } /** - * Required - API name: {@code settings} + * API name: {@code settings} *

* Adds all entries of map to settings. */ @@ -244,7 +245,7 @@ public final Builder settings(Map map) { } /** - * Required - API name: {@code settings} + * API name: {@code settings} *

* Adds an entry to settings. */ @@ -254,7 +255,7 @@ public final Builder settings(String key, IndexSettings value) { } /** - * Required - API name: {@code settings} + * API name: {@code settings} *

* Adds an entry to settings using a builder lambda. */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/FieldCapsRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/FieldCapsRequest.java index 6b8761177..46f9bf1cc 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/FieldCapsRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/FieldCapsRequest.java @@ -85,7 +85,7 @@ public class FieldCapsRequest extends RequestBase implements JsonpSerializable { @Nullable private final Query indexFilter; - private final Map> runtimeMappings; + private final Map runtimeMappings; private final List types; @@ -207,7 +207,7 @@ public final Query indexFilter() { *

* API name: {@code runtime_mappings} */ - public final Map> runtimeMappings() { + public final Map runtimeMappings() { return this.runtimeMappings; } @@ -239,16 +239,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); - for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { + for (Map.Entry item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); - generator.writeStartArray(); - if (item0.getValue() != null) { - for (RuntimeField item1 : item0.getValue()) { - item1.serialize(generator, mapper); - - } - } - generator.writeEnd(); + item0.getValue().serialize(generator, mapper); } generator.writeEnd(); @@ -288,7 +281,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement private Query indexFilter; @Nullable - private Map> runtimeMappings; + private Map runtimeMappings; @Nullable private List types; @@ -453,7 +446,7 @@ public final Builder indexFilter(Function> f *

* Adds all entries of map to runtimeMappings. */ - public final Builder runtimeMappings(Map> map) { + public final Builder runtimeMappings(Map map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } @@ -467,11 +460,25 @@ public final Builder runtimeMappings(Map> map) { *

* Adds an entry to runtimeMappings. */ - public final Builder runtimeMappings(String key, List value) { + public final Builder runtimeMappings(String key, RuntimeField value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } + /** + * Defines ad-hoc runtime fields in the request similar to the way it is done in + * search requests. These fields exist only as part of the query and take + * precedence over fields defined with the same name in the index mappings. + *

+ * API name: {@code runtime_mappings} + *

+ * Adds an entry to runtimeMappings using a builder lambda. + */ + public final Builder runtimeMappings(String key, + Function> fn) { + return runtimeMappings(key, fn.apply(new RuntimeField.Builder()).build()); + } + /** * Only return results for fields that have one of the types in the list *

@@ -525,8 +532,8 @@ public FieldCapsRequest build() { protected static void setupFieldCapsRequestDeserializer(ObjectDeserializer op) { op.add(Builder::indexFilter, Query._DESERIALIZER, "index_filter"); - op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( - JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); + op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer(RuntimeField._DESERIALIZER), + "runtime_mappings"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/SearchRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/SearchRequest.java index 4b3386f85..d4eddb256 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/SearchRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/SearchRequest.java @@ -44,6 +44,7 @@ import co.elastic.clients.elasticsearch.core.search.SourceConfig; import co.elastic.clients.elasticsearch.core.search.Suggester; import co.elastic.clients.elasticsearch.core.search.TrackHits; +import co.elastic.clients.json.JsonData; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; @@ -118,6 +119,8 @@ public class SearchRequest extends RequestBase implements JsonpSerializable { @Nullable private final Boolean explain; + private final Map ext; + private final List fields; @Nullable @@ -180,7 +183,7 @@ public class SearchRequest extends RequestBase implements JsonpSerializable { @Nullable private final String routing; - private final Map> runtimeMappings; + private final Map runtimeMappings; private final Map scriptFields; @@ -243,6 +246,7 @@ private SearchRequest(Builder builder) { this.docvalueFields = ApiTypeHelper.unmodifiable(builder.docvalueFields); this.expandWildcards = ApiTypeHelper.unmodifiable(builder.expandWildcards); this.explain = builder.explain; + this.ext = ApiTypeHelper.unmodifiable(builder.ext); this.fields = ApiTypeHelper.unmodifiable(builder.fields); this.from = builder.from; this.highlight = builder.highlight; @@ -435,6 +439,15 @@ public final Boolean explain() { return this.explain; } + /** + * Configuration of search extensions defined by Elasticsearch plugins. + *

+ * API name: {@code ext} + */ + public final Map ext() { + return this.ext; + } + /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. @@ -668,7 +681,7 @@ public final String routing() { *

* API name: {@code runtime_mappings} */ - public final Map> runtimeMappings() { + public final Map runtimeMappings() { return this.runtimeMappings; } @@ -883,6 +896,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("explain"); generator.write(this.explain); + } + if (ApiTypeHelper.isDefined(this.ext)) { + generator.writeKey("ext"); + generator.writeStartObject(); + for (Map.Entry item0 : this.ext.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + } if (ApiTypeHelper.isDefined(this.fields)) { generator.writeKey("fields"); @@ -965,16 +989,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); - for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { + for (Map.Entry item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); - generator.writeStartArray(); - if (item0.getValue() != null) { - for (RuntimeField item1 : item0.getValue()) { - item1.serialize(generator, mapper); - - } - } - generator.writeEnd(); + item0.getValue().serialize(generator, mapper); } generator.writeEnd(); @@ -1128,6 +1145,9 @@ public static class Builder extends WithJsonObjectBuilderBase implement @Nullable private Boolean explain; + @Nullable + private Map ext; + @Nullable private List fields; @@ -1195,7 +1215,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement private String routing; @Nullable - private Map> runtimeMappings; + private Map runtimeMappings; @Nullable private Map scriptFields; @@ -1474,6 +1494,30 @@ public final Builder explain(@Nullable Boolean value) { return this; } + /** + * Configuration of search extensions defined by Elasticsearch plugins. + *

+ * API name: {@code ext} + *

+ * Adds all entries of map to ext. + */ + public final Builder ext(Map map) { + this.ext = _mapPutAll(this.ext, map); + return this; + } + + /** + * Configuration of search extensions defined by Elasticsearch plugins. + *

+ * API name: {@code ext} + *

+ * Adds an entry to ext. + */ + public final Builder ext(String key, JsonData value) { + this.ext = _mapPut(this.ext, key, value); + return this; + } + /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. @@ -1832,7 +1876,7 @@ public final Builder routing(@Nullable String value) { *

* Adds all entries of map to runtimeMappings. */ - public final Builder runtimeMappings(Map> map) { + public final Builder runtimeMappings(Map map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } @@ -1845,11 +1889,24 @@ public final Builder runtimeMappings(Map> map) { *

* Adds an entry to runtimeMappings. */ - public final Builder runtimeMappings(String key, List value) { + public final Builder runtimeMappings(String key, RuntimeField value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } + /** + * Defines one or more runtime fields in the search request. These fields take + * precedence over mapped fields with the same name. + *

+ * API name: {@code runtime_mappings} + *

+ * Adds an entry to runtimeMappings using a builder lambda. + */ + public final Builder runtimeMappings(String key, + Function> fn) { + return runtimeMappings(key, fn.apply(new RuntimeField.Builder()).build()); + } + /** * Retrieve a script evaluation (based on different fields) for each hit. *

@@ -2182,6 +2239,7 @@ protected static void setupSearchRequestDeserializer(ObjectDeserializer ext; + private final List storedFields; private final List docvalueFields; @@ -137,7 +140,7 @@ public class MultisearchBody implements JsonpSerializable { @Nullable private final Boolean version; - private final Map> runtimeMappings; + private final Map runtimeMappings; @Nullable private final Boolean seqNoPrimaryTerm; @@ -156,6 +159,7 @@ private MultisearchBody(Builder builder) { this.collapse = builder.collapse; this.query = builder.query; this.explain = builder.explain; + this.ext = ApiTypeHelper.unmodifiable(builder.ext); this.storedFields = ApiTypeHelper.unmodifiable(builder.storedFields); this.docvalueFields = ApiTypeHelper.unmodifiable(builder.docvalueFields); this.knn = builder.knn; @@ -225,6 +229,15 @@ public final Boolean explain() { return this.explain; } + /** + * Configuration of search extensions defined by Elasticsearch plugins. + *

+ * API name: {@code ext} + */ + public final Map ext() { + return this.ext; + } + /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, @@ -452,7 +465,7 @@ public final Boolean version() { *

* API name: {@code runtime_mappings} */ - public final Map> runtimeMappings() { + public final Map runtimeMappings() { return this.runtimeMappings; } @@ -522,6 +535,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("explain"); generator.write(this.explain); + } + if (ApiTypeHelper.isDefined(this.ext)) { + generator.writeKey("ext"); + generator.writeStartObject(); + for (Map.Entry item0 : this.ext.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + } if (ApiTypeHelper.isDefined(this.storedFields)) { generator.writeKey("stored_fields"); @@ -690,16 +714,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); - for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { + for (Map.Entry item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); - generator.writeStartArray(); - if (item0.getValue() != null) { - for (RuntimeField item1 : item0.getValue()) { - item1.serialize(generator, mapper); - - } - } - generator.writeEnd(); + item0.getValue().serialize(generator, mapper); } generator.writeEnd(); @@ -747,6 +764,9 @@ public static class Builder extends WithJsonObjectBuilderBase implement @Nullable private Boolean explain; + @Nullable + private Map ext; + @Nullable private List storedFields; @@ -814,7 +834,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement private Boolean version; @Nullable - private Map> runtimeMappings; + private Map runtimeMappings; @Nullable private Boolean seqNoPrimaryTerm; @@ -899,6 +919,30 @@ public final Builder explain(@Nullable Boolean value) { return this; } + /** + * Configuration of search extensions defined by Elasticsearch plugins. + *

+ * API name: {@code ext} + *

+ * Adds all entries of map to ext. + */ + public final Builder ext(Map map) { + this.ext = _mapPutAll(this.ext, map); + return this; + } + + /** + * Configuration of search extensions defined by Elasticsearch plugins. + *

+ * API name: {@code ext} + *

+ * Adds an entry to ext. + */ + public final Builder ext(String key, JsonData value) { + this.ext = _mapPut(this.ext, key, value); + return this; + } + /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, @@ -1362,7 +1406,7 @@ public final Builder version(@Nullable Boolean value) { *

* Adds all entries of map to runtimeMappings. */ - public final Builder runtimeMappings(Map> map) { + public final Builder runtimeMappings(Map map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } @@ -1375,11 +1419,24 @@ public final Builder runtimeMappings(Map> map) { *

* Adds an entry to runtimeMappings. */ - public final Builder runtimeMappings(String key, List value) { + public final Builder runtimeMappings(String key, RuntimeField value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } + /** + * Defines one or more runtime fields in the search request. These fields take + * precedence over mapped fields with the same name. + *

+ * API name: {@code runtime_mappings} + *

+ * Adds an entry to runtimeMappings using a builder lambda. + */ + public final Builder runtimeMappings(String key, + Function> fn) { + return runtimeMappings(key, fn.apply(new RuntimeField.Builder()).build()); + } + /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. @@ -1460,6 +1517,7 @@ protected static void setupMultisearchBodyDeserializer(ObjectDeserializer sourceFields; - private final Map> runtimeMappings; + private final Map runtimeMappings; // --------------------------------------------------------------------------------------------- @@ -150,7 +150,7 @@ public final List sourceFields() { /** * API name: {@code runtime_mappings} */ - public final Map> runtimeMappings() { + public final Map runtimeMappings() { return this.runtimeMappings; } @@ -218,16 +218,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); - for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { + for (Map.Entry item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); - generator.writeStartArray(); - if (item0.getValue() != null) { - for (RuntimeField item1 : item0.getValue()) { - item1.serialize(generator, mapper); - - } - } - generator.writeEnd(); + item0.getValue().serialize(generator, mapper); } generator.writeEnd(); @@ -269,7 +262,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement private List sourceFields; @Nullable - private Map> runtimeMappings; + private Map runtimeMappings; /** * Required - API name: {@code index} @@ -398,7 +391,7 @@ public final Builder sourceFields(String value, String... values) { *

* Adds all entries of map to runtimeMappings. */ - public final Builder runtimeMappings(Map> map) { + public final Builder runtimeMappings(Map map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } @@ -408,11 +401,21 @@ public final Builder runtimeMappings(Map> map) { *

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

+ * Adds an entry to runtimeMappings using a builder lambda. + */ + public final Builder runtimeMappings(String key, + Function> fn) { + return runtimeMappings(key, fn.apply(new RuntimeField.Builder()).build()); + } + @Override protected Builder self() { return this; @@ -449,8 +452,8 @@ protected static void setupSourceDeserializer(ObjectDeserializer op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::sourceFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "_source"); - op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( - JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); + op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer(RuntimeField._DESERIALIZER), + "runtime_mappings"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html b/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html index d81db0a53..422b4f431 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html @@ -70,13 +70,13 @@ '_global.mget.Request': '_global/mget/MultiGetRequest.ts#L25-L91', '_global.mget.Response': '_global/mget/MultiGetResponse.ts#L22-L26', '_global.mget.ResponseItem': '_global/mget/types.ts#L57-L60', -'_global.msearch.MultiSearchItem': '_global/msearch/types.ts#L208-L211', -'_global.msearch.MultiSearchResult': '_global/msearch/types.ts#L198-L201', -'_global.msearch.MultisearchBody': '_global/msearch/types.ts#L70-L196', -'_global.msearch.MultisearchHeader': '_global/msearch/types.ts#L52-L67', +'_global.msearch.MultiSearchItem': '_global/msearch/types.ts#L213-L216', +'_global.msearch.MultiSearchResult': '_global/msearch/types.ts#L203-L206', +'_global.msearch.MultisearchBody': '_global/msearch/types.ts#L71-L201', +'_global.msearch.MultisearchHeader': '_global/msearch/types.ts#L53-L68', '_global.msearch.Request': '_global/msearch/MultiSearchRequest.ts#L25-L96', '_global.msearch.Response': '_global/msearch/MultiSearchResponse.ts#L25-L27', -'_global.msearch.ResponseItem': '_global/msearch/types.ts#L203-L206', +'_global.msearch.ResponseItem': '_global/msearch/types.ts#L208-L211', '_global.msearch_template.Request': '_global/msearch_template/MultiSearchTemplateRequest.ts#L25-L45', '_global.msearch_template.Response': '_global/msearch_template/MultiSearchTemplateResponse.ts#L22-L24', '_global.msearch_template.TemplateConfig': '_global/msearch_template/types.ts#L28-L45', @@ -124,7 +124,7 @@ '_global.scripts_painless_execute.Response': '_global/scripts_painless_execute/ExecutePainlessScriptResponse.ts#L20-L24', '_global.scroll.Request': '_global/scroll/ScrollRequest.ts#L24-L59', '_global.scroll.Response': '_global/scroll/ScrollResponse.ts#L22-L24', -'_global.search.Request': '_global/search/SearchRequest.ts#L51-L240', +'_global.search.Request': '_global/search/SearchRequest.ts#L52-L245', '_global.search.Response': '_global/search/SearchResponse.ts#L34-L36', '_global.search.ResponseBody': '_global/search/SearchResponse.ts#L38-L54', '_global.search._types.AggregationBreakdown': '_global/search/_types/profile.ts#L23-L36', @@ -576,19 +576,19 @@ '_types.analysis.HtmlStripCharFilter': '_types/analysis/char_filters.ts#L43-L45', '_types.analysis.HunspellTokenFilter': '_types/analysis/token_filters.ts#L199-L205', '_types.analysis.HyphenationDecompounderTokenFilter': '_types/analysis/token_filters.ts#L57-L59', -'_types.analysis.IcuAnalyzer': '_types/analysis/icu-plugin.ts#L66-L70', -'_types.analysis.IcuCollationAlternate': '_types/analysis/icu-plugin.ts#L88-L91', -'_types.analysis.IcuCollationCaseFirst': '_types/analysis/icu-plugin.ts#L93-L96', -'_types.analysis.IcuCollationDecomposition': '_types/analysis/icu-plugin.ts#L98-L101', -'_types.analysis.IcuCollationStrength': '_types/analysis/icu-plugin.ts#L103-L109', -'_types.analysis.IcuCollationTokenFilter': '_types/analysis/icu-plugin.ts#L51-L64', +'_types.analysis.IcuAnalyzer': '_types/analysis/icu-plugin.ts#L67-L71', +'_types.analysis.IcuCollationAlternate': '_types/analysis/icu-plugin.ts#L89-L92', +'_types.analysis.IcuCollationCaseFirst': '_types/analysis/icu-plugin.ts#L94-L97', +'_types.analysis.IcuCollationDecomposition': '_types/analysis/icu-plugin.ts#L99-L102', +'_types.analysis.IcuCollationStrength': '_types/analysis/icu-plugin.ts#L104-L110', +'_types.analysis.IcuCollationTokenFilter': '_types/analysis/icu-plugin.ts#L51-L65', '_types.analysis.IcuFoldingTokenFilter': '_types/analysis/icu-plugin.ts#L46-L49', '_types.analysis.IcuNormalizationCharFilter': '_types/analysis/icu-plugin.ts#L40-L44', -'_types.analysis.IcuNormalizationMode': '_types/analysis/icu-plugin.ts#L77-L80', +'_types.analysis.IcuNormalizationMode': '_types/analysis/icu-plugin.ts#L78-L81', '_types.analysis.IcuNormalizationTokenFilter': '_types/analysis/icu-plugin.ts#L35-L38', -'_types.analysis.IcuNormalizationType': '_types/analysis/icu-plugin.ts#L82-L86', +'_types.analysis.IcuNormalizationType': '_types/analysis/icu-plugin.ts#L83-L87', '_types.analysis.IcuTokenizer': '_types/analysis/icu-plugin.ts#L30-L33', -'_types.analysis.IcuTransformDirection': '_types/analysis/icu-plugin.ts#L72-L75', +'_types.analysis.IcuTransformDirection': '_types/analysis/icu-plugin.ts#L73-L76', '_types.analysis.IcuTransformTokenFilter': '_types/analysis/icu-plugin.ts#L24-L28', '_types.analysis.KStemTokenFilter': '_types/analysis/token_filters.ts#L238-L240', '_types.analysis.KeepTypesMode': '_types/analysis/token_filters.ts#L212-L215', @@ -856,7 +856,7 @@ 'async_search.status.Request': 'async_search/status/AsyncSearchStatusRequest.ts#L23-L33', 'async_search.status.Response': 'async_search/status/AsyncSearchStatusResponse.ts#L28-L30', 'async_search.status.StatusResponseBase': 'async_search/status/AsyncSearchStatusResponse.ts#L24-L27', -'async_search.submit.Request': 'async_search/submit/AsyncSearchSubmitRequest.ts#L54-L250', +'async_search.submit.Request': 'async_search/submit/AsyncSearchSubmitRequest.ts#L55-L255', 'async_search.submit.Response': 'async_search/submit/AsyncSearchSubmitResponse.ts#L22-L24', 'autoscaling._types.AutoscalingPolicy': 'autoscaling/_types/AutoscalingPolicy.ts#L23-L27', 'autoscaling.delete_autoscaling_policy.Request': 'autoscaling/delete_autoscaling_policy/DeleteAutoscalingPolicyRequest.ts#L23-L33', @@ -1126,7 +1126,7 @@ 'features.get_features.Response': 'features/get_features/GetFeaturesResponse.ts#L22-L26', 'features.reset_features.Request': 'features/reset_features/ResetFeaturesRequest.ts#L22-L27', 'features.reset_features.Response': 'features/reset_features/ResetFeaturesResponse.ts#L22-L26', -'fleet.search.Request': 'fleet/search/SearchRequest.ts#L54-L255', +'fleet.search.Request': 'fleet/search/SearchRequest.ts#L55-L260', 'fleet.search.Response': 'fleet/search/SearchResponse.ts#L33-L50', 'graph._types.Connection': 'graph/_types/Connection.ts#L22-L27', 'graph._types.ExploreControls': 'graph/_types/ExploreControls.ts#L24-L29', @@ -1173,7 +1173,7 @@ 'ilm.stop.Response': 'ilm/stop/StopIlmResponse.ts#L22-L24', 'indices._types.Alias': 'indices/_types/Alias.ts#L23-L30', 'indices._types.AliasDefinition': 'indices/_types/AliasDefinition.ts#L22-L30', -'indices._types.CacheQueries': 'indices/_types/IndexSettings.ts#L398-L400', +'indices._types.CacheQueries': 'indices/_types/IndexSettings.ts#L397-L399', 'indices._types.DataStream': 'indices/_types/DataStream.ts#L31-L46', 'indices._types.DataStreamIndex': 'indices/_types/DataStream.ts#L52-L55', 'indices._types.DataStreamTimestampField': 'indices/_types/DataStream.ts#L48-L50', @@ -1191,29 +1191,29 @@ 'indices._types.IndexSegmentSort': 'indices/_types/IndexSegmentSort.ts#L22-L27', 'indices._types.IndexSettingBlocks': 'indices/_types/IndexSettings.ts#L245-L251', 'indices._types.IndexSettings': 'indices/_types/IndexSettings.ts#L69-L168', -'indices._types.IndexSettingsAnalysis': 'indices/_types/IndexSettings.ts#L310-L316', -'indices._types.IndexSettingsLifecycle': 'indices/_types/IndexSettings.ts#L267-L300', -'indices._types.IndexSettingsLifecycleStep': 'indices/_types/IndexSettings.ts#L302-L308', -'indices._types.IndexSettingsTimeSeries': 'indices/_types/IndexSettings.ts#L318-L321', +'indices._types.IndexSettingsAnalysis': 'indices/_types/IndexSettings.ts#L309-L315', +'indices._types.IndexSettingsLifecycle': 'indices/_types/IndexSettings.ts#L266-L299', +'indices._types.IndexSettingsLifecycleStep': 'indices/_types/IndexSettings.ts#L301-L307', +'indices._types.IndexSettingsTimeSeries': 'indices/_types/IndexSettings.ts#L317-L320', 'indices._types.IndexState': 'indices/_types/IndexState.ts#L26-L33', 'indices._types.IndexTemplate': 'indices/_types/IndexTemplate.ts#L27-L37', 'indices._types.IndexTemplateDataStreamConfiguration': 'indices/_types/IndexTemplate.ts#L39-L50', 'indices._types.IndexTemplateSummary': 'indices/_types/IndexTemplate.ts#L52-L56', -'indices._types.IndexVersioning': 'indices/_types/IndexSettings.ts#L262-L265', -'indices._types.IndexingPressure': 'indices/_types/IndexSettings.ts#L536-L538', -'indices._types.IndexingPressureMemory': 'indices/_types/IndexSettings.ts#L540-L547', -'indices._types.MappingLimitSettings': 'indices/_types/IndexSettings.ts#L402-L414', -'indices._types.MappingLimitSettingsDepth': 'indices/_types/IndexSettings.ts#L426-L433', -'indices._types.MappingLimitSettingsDimensionFields': 'indices/_types/IndexSettings.ts#L463-L469', -'indices._types.MappingLimitSettingsFieldNameLength': 'indices/_types/IndexSettings.ts#L454-L461', -'indices._types.MappingLimitSettingsNestedFields': 'indices/_types/IndexSettings.ts#L435-L443', -'indices._types.MappingLimitSettingsNestedObjects': 'indices/_types/IndexSettings.ts#L445-L452', -'indices._types.MappingLimitSettingsTotalFields': 'indices/_types/IndexSettings.ts#L416-L424', -'indices._types.Merge': 'indices/_types/IndexSettings.ts#L323-L325', -'indices._types.MergeScheduler': 'indices/_types/IndexSettings.ts#L327-L330', +'indices._types.IndexVersioning': 'indices/_types/IndexSettings.ts#L262-L264', +'indices._types.IndexingPressure': 'indices/_types/IndexSettings.ts#L535-L537', +'indices._types.IndexingPressureMemory': 'indices/_types/IndexSettings.ts#L539-L546', +'indices._types.MappingLimitSettings': 'indices/_types/IndexSettings.ts#L401-L413', +'indices._types.MappingLimitSettingsDepth': 'indices/_types/IndexSettings.ts#L425-L432', +'indices._types.MappingLimitSettingsDimensionFields': 'indices/_types/IndexSettings.ts#L462-L468', +'indices._types.MappingLimitSettingsFieldNameLength': 'indices/_types/IndexSettings.ts#L453-L460', +'indices._types.MappingLimitSettingsNestedFields': 'indices/_types/IndexSettings.ts#L434-L442', +'indices._types.MappingLimitSettingsNestedObjects': 'indices/_types/IndexSettings.ts#L444-L451', +'indices._types.MappingLimitSettingsTotalFields': 'indices/_types/IndexSettings.ts#L415-L423', +'indices._types.Merge': 'indices/_types/IndexSettings.ts#L322-L324', +'indices._types.MergeScheduler': 'indices/_types/IndexSettings.ts#L326-L329', 'indices._types.NumericFielddata': 'indices/_types/NumericFielddata.ts#L22-L24', 'indices._types.NumericFielddataFormat': 'indices/_types/NumericFielddataFormat.ts#L20-L23', -'indices._types.Queries': 'indices/_types/IndexSettings.ts#L394-L396', +'indices._types.Queries': 'indices/_types/IndexSettings.ts#L393-L395', 'indices._types.RetentionLease': 'indices/_types/IndexSettings.ts#L65-L67', 'indices._types.SearchIdle': 'indices/_types/IndexSettings.ts#L236-L239', 'indices._types.SegmentSortMissing': 'indices/_types/IndexSegmentSort.ts#L43-L48', @@ -1231,16 +1231,16 @@ 'indices._types.SettingsSimilarityLmd': 'indices/_types/IndexSettings.ts#L206-L209', 'indices._types.SettingsSimilarityLmj': 'indices/_types/IndexSettings.ts#L211-L214', 'indices._types.SettingsSimilarityScriptedTfidf': 'indices/_types/IndexSettings.ts#L216-L219', -'indices._types.SlowlogSettings': 'indices/_types/IndexSettings.ts#L471-L476', -'indices._types.SlowlogTresholdLevels': 'indices/_types/IndexSettings.ts#L489-L494', -'indices._types.SlowlogTresholds': 'indices/_types/IndexSettings.ts#L478-L487', +'indices._types.SlowlogSettings': 'indices/_types/IndexSettings.ts#L470-L475', +'indices._types.SlowlogTresholdLevels': 'indices/_types/IndexSettings.ts#L488-L493', +'indices._types.SlowlogTresholds': 'indices/_types/IndexSettings.ts#L477-L486', 'indices._types.SoftDeletes': 'indices/_types/IndexSettings.ts#L50-L63', -'indices._types.Storage': 'indices/_types/IndexSettings.ts#L496-L505', -'indices._types.StorageType': 'indices/_types/IndexSettings.ts#L507-L534', +'indices._types.Storage': 'indices/_types/IndexSettings.ts#L495-L504', +'indices._types.StorageType': 'indices/_types/IndexSettings.ts#L506-L533', 'indices._types.TemplateMapping': 'indices/_types/TemplateMapping.ts#L27-L34', -'indices._types.Translog': 'indices/_types/IndexSettings.ts#L332-L354', -'indices._types.TranslogDurability': 'indices/_types/IndexSettings.ts#L356-L371', -'indices._types.TranslogRetention': 'indices/_types/IndexSettings.ts#L373-L392', +'indices._types.Translog': 'indices/_types/IndexSettings.ts#L331-L353', +'indices._types.TranslogDurability': 'indices/_types/IndexSettings.ts#L355-L370', +'indices._types.TranslogRetention': 'indices/_types/IndexSettings.ts#L372-L391', 'indices.add_block.IndicesBlockOptions': 'indices/add_block/IndicesAddBlockRequest.ts#L43-L48', 'indices.add_block.IndicesBlockStatus': 'indices/add_block/IndicesAddBlockResponse.ts#L30-L33', 'indices.add_block.Request': 'indices/add_block/IndicesAddBlockRequest.ts#L24-L41', @@ -2515,10 +2515,10 @@ if (hash.length > 1) { hash = hash.substring(1); } - window.location = "https://github.com/elastic/elasticsearch-specification/tree/c91bc8023c26c13e790cc04c86201047bd4af5da/specification/" + (paths[hash] || ""); + window.location = "https://github.com/elastic/elasticsearch-specification/tree/76aabb3c0ee07e0237b9462c180584d07e080a23/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/eql/EqlSearchRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/eql/EqlSearchRequest.java index 47f879c4e..a70a6e775 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/eql/EqlSearchRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/eql/EqlSearchRequest.java @@ -98,7 +98,7 @@ public class EqlSearchRequest extends RequestBase implements JsonpSerializable { @Nullable private final ResultPosition resultPosition; - private final Map> runtimeMappings; + private final Map runtimeMappings; @Nullable private final Number size; @@ -259,7 +259,7 @@ public final ResultPosition resultPosition() { /** * API name: {@code runtime_mappings} */ - public final Map> runtimeMappings() { + public final Map runtimeMappings() { return this.runtimeMappings; } @@ -368,16 +368,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); - for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { + for (Map.Entry item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); - generator.writeStartArray(); - if (item0.getValue() != null) { - for (RuntimeField item1 : item0.getValue()) { - item1.serialize(generator, mapper); - - } - } - generator.writeEnd(); + item0.getValue().serialize(generator, mapper); } generator.writeEnd(); @@ -451,7 +444,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement private ResultPosition resultPosition; @Nullable - private Map> runtimeMappings; + private Map runtimeMappings; @Nullable private Number size; @@ -677,7 +670,7 @@ public final Builder resultPosition(@Nullable ResultPosition value) { *

* Adds all entries of map to runtimeMappings. */ - public final Builder runtimeMappings(Map> map) { + public final Builder runtimeMappings(Map map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } @@ -687,11 +680,21 @@ public final Builder runtimeMappings(Map> map) { *

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

+ * Adds an entry to runtimeMappings using a builder lambda. + */ + public final Builder runtimeMappings(String key, + Function> fn) { + return runtimeMappings(key, fn.apply(new RuntimeField.Builder()).build()); + } + /** * For basic queries, the maximum number of matching events to return. Defaults * to 10 @@ -775,8 +778,8 @@ protected static void setupEqlSearchRequestDeserializer(ObjectDeserializer ext; + private final List fields; @Nullable @@ -178,7 +181,7 @@ public class FleetSearchRequest extends RequestBase implements JsonpSerializable @Nullable private final String routing; - private final Map> runtimeMappings; + private final Map runtimeMappings; private final Map scriptFields; @@ -243,6 +246,7 @@ private FleetSearchRequest(Builder builder) { this.docvalueFields = ApiTypeHelper.unmodifiable(builder.docvalueFields); this.expandWildcards = ApiTypeHelper.unmodifiable(builder.expandWildcards); this.explain = builder.explain; + this.ext = ApiTypeHelper.unmodifiable(builder.ext); this.fields = ApiTypeHelper.unmodifiable(builder.fields); this.from = builder.from; this.highlight = builder.highlight; @@ -414,6 +418,15 @@ public final Boolean explain() { return this.explain; } + /** + * Configuration of search extensions defined by Elasticsearch plugins. + *

+ * API name: {@code ext} + */ + public final Map ext() { + return this.ext; + } + /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. @@ -604,7 +617,7 @@ public final String routing() { *

* API name: {@code runtime_mappings} */ - public final Map> runtimeMappings() { + public final Map runtimeMappings() { return this.runtimeMappings; } @@ -826,6 +839,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("explain"); generator.write(this.explain); + } + if (ApiTypeHelper.isDefined(this.ext)) { + generator.writeKey("ext"); + generator.writeStartObject(); + for (Map.Entry item0 : this.ext.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + + } + generator.writeEnd(); + } if (ApiTypeHelper.isDefined(this.fields)) { generator.writeKey("fields"); @@ -903,16 +927,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); - for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { + for (Map.Entry item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); - generator.writeStartArray(); - if (item0.getValue() != null) { - for (RuntimeField item1 : item0.getValue()) { - item1.serialize(generator, mapper); - - } - } - generator.writeEnd(); + item0.getValue().serialize(generator, mapper); } generator.writeEnd(); @@ -1068,6 +1085,9 @@ public static class Builder extends WithJsonObjectBuilderBase @Nullable private Boolean explain; + @Nullable + private Map ext; + @Nullable private List fields; @@ -1131,7 +1151,7 @@ public static class Builder extends WithJsonObjectBuilderBase private String routing; @Nullable - private Map> runtimeMappings; + private Map runtimeMappings; @Nullable private Map scriptFields; @@ -1389,6 +1409,30 @@ public final Builder explain(@Nullable Boolean value) { return this; } + /** + * Configuration of search extensions defined by Elasticsearch plugins. + *

+ * API name: {@code ext} + *

+ * Adds all entries of map to ext. + */ + public final Builder ext(Map map) { + this.ext = _mapPutAll(this.ext, map); + return this; + } + + /** + * Configuration of search extensions defined by Elasticsearch plugins. + *

+ * API name: {@code ext} + *

+ * Adds an entry to ext. + */ + public final Builder ext(String key, JsonData value) { + this.ext = _mapPut(this.ext, key, value); + return this; + } + /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. @@ -1680,7 +1724,7 @@ public final Builder routing(@Nullable String value) { *

* Adds all entries of map to runtimeMappings. */ - public final Builder runtimeMappings(Map> map) { + public final Builder runtimeMappings(Map map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } @@ -1693,11 +1737,24 @@ public final Builder runtimeMappings(Map> map) { *

* Adds an entry to runtimeMappings. */ - public final Builder runtimeMappings(String key, List value) { + public final Builder runtimeMappings(String key, RuntimeField value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } + /** + * Defines one or more runtime fields in the search request. These fields take + * precedence over mapped fields with the same name. + *

+ * API name: {@code runtime_mappings} + *

+ * Adds an entry to runtimeMappings using a builder lambda. + */ + public final Builder runtimeMappings(String key, + Function> fn) { + return runtimeMappings(key, fn.apply(new RuntimeField.Builder()).build()); + } + /** * Retrieve a script evaluation (based on different fields) for each hit. *

@@ -2052,6 +2109,7 @@ protected static void setupFleetSearchRequestDeserializer(ObjectDeserializer implements ObjectBuilder { - private String created; - @Nullable - private String createdString; + private String created; /** - * Required - API name: {@code created} + * API name: {@code created} */ - public final Builder created(String value) { + public final Builder created(@Nullable String value) { this.created = value; return this; } - /** - * API name: {@code created_string} - */ - public final Builder createdString(@Nullable String value) { - this.createdString = value; - return this; - } - @Override protected Builder self() { return this; @@ -165,7 +141,6 @@ public IndexVersioning build() { protected static void setupIndexVersioningDeserializer(ObjectDeserializer op) { op.add(Builder::created, JsonpDeserializer.stringDeserializer(), "created"); - op.add(Builder::createdString, JsonpDeserializer.stringDeserializer(), "created_string"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/PutMappingRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/PutMappingRequest.java index a96d3b54e..009667dfb 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/PutMappingRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/PutMappingRequest.java @@ -106,7 +106,7 @@ public class PutMappingRequest extends RequestBase implements JsonpSerializable private final Map properties; - private final Map> runtime; + private final Map runtime; @Nullable private final Time timeout; @@ -307,7 +307,7 @@ public final Map properties() { *

* API name: {@code runtime} */ - public final Map> runtime() { + public final Map runtime() { return this.runtime; } @@ -425,16 +425,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.runtime)) { generator.writeKey("runtime"); generator.writeStartObject(); - for (Map.Entry> item0 : this.runtime.entrySet()) { + for (Map.Entry item0 : this.runtime.entrySet()) { generator.writeKey(item0.getKey()); - generator.writeStartArray(); - if (item0.getValue() != null) { - for (RuntimeField item1 : item0.getValue()) { - item1.serialize(generator, mapper); - - } - } - generator.writeEnd(); + item0.getValue().serialize(generator, mapper); } generator.writeEnd(); @@ -495,7 +488,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement private Map properties; @Nullable - private Map> runtime; + private Map runtime; @Nullable private Time timeout; @@ -824,7 +817,7 @@ public final Builder properties(String key, Function * Adds all entries of map to runtime. */ - public final Builder runtime(Map> map) { + public final Builder runtime(Map map) { this.runtime = _mapPutAll(this.runtime, map); return this; } @@ -836,11 +829,22 @@ public final Builder runtime(Map> map) { *

* Adds an entry to runtime. */ - public final Builder runtime(String key, List value) { + public final Builder runtime(String key, RuntimeField value) { this.runtime = _mapPut(this.runtime, key, value); return this; } + /** + * Mapping of runtime fields for the index. + *

+ * API name: {@code runtime} + *

+ * Adds an entry to runtime using a builder lambda. + */ + public final Builder runtime(String key, Function> fn) { + return runtime(key, fn.apply(new RuntimeField.Builder()).build()); + } + /** * Explicit operation timeout *

@@ -911,8 +915,7 @@ protected static void setupPutMappingRequestDeserializer(ObjectDeserializer> runtimeMappings; + private final Map runtimeMappings; @Nullable private final IndicesOptions indicesOptions; @@ -235,7 +235,7 @@ public final DelayedDataCheckConfig delayedDataCheckConfig() { /** * API name: {@code runtime_mappings} */ - public final Map> runtimeMappings() { + public final Map runtimeMappings() { return this.runtimeMappings; } @@ -345,16 +345,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); - for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { + for (Map.Entry item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); - generator.writeStartArray(); - if (item0.getValue() != null) { - for (RuntimeField item1 : item0.getValue()) { - item1.serialize(generator, mapper); - - } - } - generator.writeEnd(); + item0.getValue().serialize(generator, mapper); } generator.writeEnd(); @@ -418,7 +411,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement private DelayedDataCheckConfig delayedDataCheckConfig; @Nullable - private Map> runtimeMappings; + private Map runtimeMappings; @Nullable private IndicesOptions indicesOptions; @@ -658,7 +651,7 @@ public final Builder delayedDataCheckConfig( *

* Adds all entries of map to runtimeMappings. */ - public final Builder runtimeMappings(Map> map) { + public final Builder runtimeMappings(Map map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } @@ -668,11 +661,21 @@ public final Builder runtimeMappings(Map> map) { *

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

+ * Adds an entry to runtimeMappings using a builder lambda. + */ + public final Builder runtimeMappings(String key, + Function> fn) { + return runtimeMappings(key, fn.apply(new RuntimeField.Builder()).build()); + } + /** * API name: {@code indices_options} */ @@ -734,8 +737,8 @@ protected static void setupDatafeedDeserializer(ObjectDeserializer> runtimeMappings; + private final Map runtimeMappings; private final Map scriptFields; @@ -276,7 +276,7 @@ public final Time queryDelay() { *

* API name: {@code runtime_mappings} */ - public final Map> runtimeMappings() { + public final Map runtimeMappings() { return this.runtimeMappings; } @@ -391,16 +391,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); - for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { + for (Map.Entry item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); - generator.writeStartArray(); - if (item0.getValue() != null) { - for (RuntimeField item1 : item0.getValue()) { - item1.serialize(generator, mapper); - - } - } - generator.writeEnd(); + item0.getValue().serialize(generator, mapper); } generator.writeEnd(); @@ -472,7 +465,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement private Time queryDelay; @Nullable - private Map> runtimeMappings; + private Map runtimeMappings; @Nullable private Map scriptFields; @@ -775,7 +768,7 @@ public final Builder queryDelay(Function> fn) *

* Adds all entries of map to runtimeMappings. */ - public final Builder runtimeMappings(Map> map) { + public final Builder runtimeMappings(Map map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } @@ -787,11 +780,23 @@ public final Builder runtimeMappings(Map> map) { *

* Adds an entry to runtimeMappings. */ - public final Builder runtimeMappings(String key, List value) { + public final Builder runtimeMappings(String key, RuntimeField value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } + /** + * Specifies runtime fields for the datafeed search. + *

+ * API name: {@code runtime_mappings} + *

+ * Adds an entry to runtimeMappings using a builder lambda. + */ + public final Builder runtimeMappings(String key, + Function> fn) { + return runtimeMappings(key, fn.apply(new RuntimeField.Builder()).build()); + } + /** * Specifies scripts that evaluate custom expressions and returns script fields * to the datafeed. The detector configuration objects in a job can contain @@ -888,8 +893,8 @@ protected static void setupDatafeedConfigDeserializer(ObjectDeserializer> runtimeMappings; + private final Map runtimeMappings; @Nullable private final DataframeAnalysisAnalyzedFields source; @@ -110,7 +110,7 @@ public final Query query() { *

* API name: {@code runtime_mappings} */ - public final Map> runtimeMappings() { + public final Map runtimeMappings() { return this.runtimeMappings; } @@ -155,16 +155,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); - for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { + for (Map.Entry item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); - generator.writeStartArray(); - if (item0.getValue() != null) { - for (RuntimeField item1 : item0.getValue()) { - item1.serialize(generator, mapper); - - } - } - generator.writeEnd(); + item0.getValue().serialize(generator, mapper); } generator.writeEnd(); @@ -198,7 +191,7 @@ public static class Builder extends WithJsonObjectBuilderBase private Query query; @Nullable - private Map> runtimeMappings; + private Map runtimeMappings; @Nullable private DataframeAnalysisAnalyzedFields source; @@ -268,7 +261,7 @@ public final Builder query(Function> fn) { *

* Adds all entries of map to runtimeMappings. */ - public final Builder runtimeMappings(Map> map) { + public final Builder runtimeMappings(Map map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } @@ -281,11 +274,24 @@ public final Builder runtimeMappings(Map> map) { *

* Adds an entry to runtimeMappings. */ - public final Builder runtimeMappings(String key, List value) { + public final Builder runtimeMappings(String key, RuntimeField value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } + /** + * Definitions of runtime fields that will become part of the mapping of the + * destination index. + *

+ * API name: {@code runtime_mappings} + *

+ * Adds an entry to runtimeMappings using a builder lambda. + */ + public final Builder runtimeMappings(String key, + Function> fn) { + return runtimeMappings(key, fn.apply(new RuntimeField.Builder()).build()); + } + /** * Specify includes and/or `excludes patterns to select which * fields will be present in the destination. Fields that are excluded cannot be @@ -341,8 +347,8 @@ protected static void setupDataframeAnalyticsSourceDeserializer( op.add(Builder::index, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "index"); op.add(Builder::query, Query._DESERIALIZER, "query"); - op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( - JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); + op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer(RuntimeField._DESERIALIZER), + "runtime_mappings"); op.add(Builder::source, DataframeAnalysisAnalyzedFields._DESERIALIZER, "_source"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/GetModelSnapshotUpgradeStatsRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/GetModelSnapshotUpgradeStatsRequest.java index 08d541e18..b629350a5 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/GetModelSnapshotUpgradeStatsRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/GetModelSnapshotUpgradeStatsRequest.java @@ -60,7 +60,6 @@ public class GetModelSnapshotUpgradeStatsRequest extends RequestBase { private final String jobId; - @Nullable private final String snapshotId; // --------------------------------------------------------------------------------------------- @@ -69,7 +68,7 @@ private GetModelSnapshotUpgradeStatsRequest(Builder builder) { this.allowNoMatch = builder.allowNoMatch; this.jobId = ApiTypeHelper.requireNonNull(builder.jobId, this, "jobId"); - this.snapshotId = builder.snapshotId; + this.snapshotId = ApiTypeHelper.requireNonNull(builder.snapshotId, this, "snapshotId"); } @@ -108,15 +107,14 @@ public final String jobId() { } /** - * A numerical character string that uniquely identifies the model snapshot. You - * can get information for multiple snapshots by using a comma-separated list or - * a wildcard expression. You can get all snapshots by using _all, - * by specifying * as the snapshot ID, or by omitting the snapshot - * ID. + * Required - A numerical character string that uniquely identifies the model + * snapshot. You can get information for multiple snapshots by using a + * comma-separated list or a wildcard expression. You can get all snapshots by + * using _all, by specifying * as the snapshot ID, or + * by omitting the snapshot ID. *

* API name: {@code snapshot_id} */ - @Nullable public final String snapshotId() { return this.snapshotId; } @@ -135,7 +133,6 @@ public static class Builder extends ObjectBuilderBase private String jobId; - @Nullable private String snapshotId; /** @@ -169,15 +166,15 @@ public final Builder jobId(String value) { } /** - * A numerical character string that uniquely identifies the model snapshot. You - * can get information for multiple snapshots by using a comma-separated list or - * a wildcard expression. You can get all snapshots by using _all, - * by specifying * as the snapshot ID, or by omitting the snapshot - * ID. + * Required - A numerical character string that uniquely identifies the model + * snapshot. You can get information for multiple snapshots by using a + * comma-separated list or a wildcard expression. You can get all snapshots by + * using _all, by specifying * as the snapshot ID, or + * by omitting the snapshot ID. *

* API name: {@code snapshot_id} */ - public final Builder snapshotId(@Nullable String value) { + public final Builder snapshotId(String value) { this.snapshotId = value; return this; } @@ -216,8 +213,7 @@ public GetModelSnapshotUpgradeStatsRequest build() { int propsSet = 0; - if (request.snapshotId() != null) - propsSet |= _snapshotId; + propsSet |= _snapshotId; propsSet |= _jobId; if (propsSet == (_jobId | _snapshotId)) { diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/PutDatafeedRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/PutDatafeedRequest.java index b7cc95dcb..37912afc9 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/PutDatafeedRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/PutDatafeedRequest.java @@ -114,7 +114,7 @@ public class PutDatafeedRequest extends RequestBase implements JsonpSerializable @Nullable private final Time queryDelay; - private final Map> runtimeMappings; + private final Map runtimeMappings; private final Map scriptFields; @@ -352,7 +352,7 @@ public final Time queryDelay() { *

* API name: {@code runtime_mappings} */ - public final Map> runtimeMappings() { + public final Map runtimeMappings() { return this.runtimeMappings; } @@ -472,16 +472,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); - for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { + for (Map.Entry item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); - generator.writeStartArray(); - if (item0.getValue() != null) { - for (RuntimeField item1 : item0.getValue()) { - item1.serialize(generator, mapper); - - } - } - generator.writeEnd(); + item0.getValue().serialize(generator, mapper); } generator.writeEnd(); @@ -563,7 +556,7 @@ public static class Builder extends WithJsonObjectBuilderBase private Time queryDelay; @Nullable - private Map> runtimeMappings; + private Map runtimeMappings; @Nullable private Map scriptFields; @@ -929,7 +922,7 @@ public final Builder queryDelay(Function> fn) *

* Adds all entries of map to runtimeMappings. */ - public final Builder runtimeMappings(Map> map) { + public final Builder runtimeMappings(Map map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } @@ -941,11 +934,23 @@ public final Builder runtimeMappings(Map> map) { *

* Adds an entry to runtimeMappings. */ - public final Builder runtimeMappings(String key, List value) { + public final Builder runtimeMappings(String key, RuntimeField value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } + /** + * Specifies runtime fields for the datafeed search. + *

+ * API name: {@code runtime_mappings} + *

+ * Adds an entry to runtimeMappings using a builder lambda. + */ + public final Builder runtimeMappings(String key, + Function> fn) { + return runtimeMappings(key, fn.apply(new RuntimeField.Builder()).build()); + } + /** * Specifies scripts that evaluate custom expressions and returns script fields * to the datafeed. The detector configuration objects in a job can contain @@ -1041,8 +1046,8 @@ protected static void setupPutDatafeedRequestDeserializer(ObjectDeserializer> runtimeMappings; + private final Map runtimeMappings; private final Map scriptFields; @@ -206,7 +206,7 @@ public final Time queryDelay() { /** * API name: {@code runtime_mappings} */ - public final Map> runtimeMappings() { + public final Map runtimeMappings() { return this.runtimeMappings; } @@ -295,16 +295,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); - for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { + for (Map.Entry item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); - generator.writeStartArray(); - if (item0.getValue() != null) { - for (RuntimeField item1 : item0.getValue()) { - item1.serialize(generator, mapper); - - } - } - generator.writeEnd(); + item0.getValue().serialize(generator, mapper); } generator.writeEnd(); @@ -368,7 +361,7 @@ public static class Builder extends WithJsonObjectBuilderBase private Time queryDelay; @Nullable - private Map> runtimeMappings; + private Map runtimeMappings; @Nullable private Map scriptFields; @@ -560,7 +553,7 @@ public final Builder queryDelay(Function> fn) *

* Adds all entries of map to runtimeMappings. */ - public final Builder runtimeMappings(Map> map) { + public final Builder runtimeMappings(Map map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } @@ -570,11 +563,21 @@ public final Builder runtimeMappings(Map> map) { *

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

+ * Adds an entry to runtimeMappings using a builder lambda. + */ + public final Builder runtimeMappings(String key, + Function> fn) { + return runtimeMappings(key, fn.apply(new RuntimeField.Builder()).build()); + } + /** * API name: {@code script_fields} *

@@ -654,8 +657,8 @@ protected static void setupPutDatafeedResponseDeserializer(ObjectDeserializer> runtimeMappings; + private final Map runtimeMappings; private final Map scriptFields; @@ -342,7 +342,7 @@ public final Time queryDelay() { *

* API name: {@code runtime_mappings} */ - public final Map> runtimeMappings() { + public final Map runtimeMappings() { return this.runtimeMappings; } @@ -439,16 +439,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); - for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { + for (Map.Entry item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); - generator.writeStartArray(); - if (item0.getValue() != null) { - for (RuntimeField item1 : item0.getValue()) { - item1.serialize(generator, mapper); - - } - } - generator.writeEnd(); + item0.getValue().serialize(generator, mapper); } generator.writeEnd(); @@ -524,7 +517,7 @@ public static class Builder extends WithJsonObjectBuilderBase private Time queryDelay; @Nullable - private Map> runtimeMappings; + private Map runtimeMappings; @Nullable private Map scriptFields; @@ -891,7 +884,7 @@ public final Builder queryDelay(Function> fn) *

* Adds all entries of map to runtimeMappings. */ - public final Builder runtimeMappings(Map> map) { + public final Builder runtimeMappings(Map map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } @@ -903,11 +896,23 @@ public final Builder runtimeMappings(Map> map) { *

* Adds an entry to runtimeMappings. */ - public final Builder runtimeMappings(String key, List value) { + public final Builder runtimeMappings(String key, RuntimeField value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } + /** + * Specifies runtime fields for the datafeed search. + *

+ * API name: {@code runtime_mappings} + *

+ * Adds an entry to runtimeMappings using a builder lambda. + */ + public final Builder runtimeMappings(String key, + Function> fn) { + return runtimeMappings(key, fn.apply(new RuntimeField.Builder()).build()); + } + /** * Specifies scripts that evaluate custom expressions and returns script fields * to the datafeed. The detector configuration objects in a job can contain @@ -1000,8 +1005,8 @@ protected static void setupUpdateDatafeedRequestDeserializer(ObjectDeserializer< op.add(Builder::maxEmptySearches, JsonpDeserializer.integerDeserializer(), "max_empty_searches"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::queryDelay, Time._DESERIALIZER, "query_delay"); - op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( - JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); + op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer(RuntimeField._DESERIALIZER), + "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::scrollSize, JsonpDeserializer.integerDeserializer(), "scroll_size"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/UpdateDatafeedResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/UpdateDatafeedResponse.java index 975a32953..ac4f94ac5 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/UpdateDatafeedResponse.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/ml/UpdateDatafeedResponse.java @@ -84,7 +84,7 @@ public class UpdateDatafeedResponse implements JsonpSerializable { private final Time queryDelay; - private final Map> runtimeMappings; + private final Map runtimeMappings; private final Map scriptFields; @@ -206,7 +206,7 @@ public final Time queryDelay() { /** * API name: {@code runtime_mappings} */ - public final Map> runtimeMappings() { + public final Map runtimeMappings() { return this.runtimeMappings; } @@ -295,16 +295,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); - for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { + for (Map.Entry item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); - generator.writeStartArray(); - if (item0.getValue() != null) { - for (RuntimeField item1 : item0.getValue()) { - item1.serialize(generator, mapper); - - } - } - generator.writeEnd(); + item0.getValue().serialize(generator, mapper); } generator.writeEnd(); @@ -368,7 +361,7 @@ public static class Builder extends WithJsonObjectBuilderBase private Time queryDelay; @Nullable - private Map> runtimeMappings; + private Map runtimeMappings; @Nullable private Map scriptFields; @@ -560,7 +553,7 @@ public final Builder queryDelay(Function> fn) *

* Adds all entries of map to runtimeMappings. */ - public final Builder runtimeMappings(Map> map) { + public final Builder runtimeMappings(Map map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } @@ -570,11 +563,21 @@ public final Builder runtimeMappings(Map> map) { *

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

+ * Adds an entry to runtimeMappings using a builder lambda. + */ + public final Builder runtimeMappings(String key, + Function> fn) { + return runtimeMappings(key, fn.apply(new RuntimeField.Builder()).build()); + } + /** * API name: {@code script_fields} *

@@ -655,8 +658,8 @@ protected static void setupUpdateDatafeedResponseDeserializer( op.add(Builder::maxEmptySearches, JsonpDeserializer.integerDeserializer(), "max_empty_searches"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::queryDelay, Time._DESERIALIZER, "query_delay"); - op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( - JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); + op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer(RuntimeField._DESERIALIZER), + "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::scrollSize, JsonpDeserializer.integerDeserializer(), "scroll_size"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetTokenResponse.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetTokenResponse.java index 2cae77849..a7a268eff 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetTokenResponse.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/security/GetTokenResponse.java @@ -59,6 +59,7 @@ public class GetTokenResponse implements JsonpSerializable { private final String type; + @Nullable private final String refreshToken; @Nullable @@ -74,7 +75,7 @@ private GetTokenResponse(Builder builder) { this.expiresIn = ApiTypeHelper.requireNonNull(builder.expiresIn, this, "expiresIn"); this.scope = builder.scope; this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type"); - this.refreshToken = ApiTypeHelper.requireNonNull(builder.refreshToken, this, "refreshToken"); + this.refreshToken = builder.refreshToken; this.kerberosAuthenticationResponseToken = builder.kerberosAuthenticationResponseToken; this.authentication = ApiTypeHelper.requireNonNull(builder.authentication, this, "authentication"); @@ -114,8 +115,9 @@ public final String type() { } /** - * Required - API name: {@code refresh_token} + * API name: {@code refresh_token} */ + @Nullable public final String refreshToken() { return this.refreshToken; } @@ -160,9 +162,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("type"); generator.write(this.type); - generator.writeKey("refresh_token"); - generator.write(this.refreshToken); + if (this.refreshToken != null) { + generator.writeKey("refresh_token"); + generator.write(this.refreshToken); + } if (this.kerberosAuthenticationResponseToken != null) { generator.writeKey("kerberos_authentication_response_token"); generator.write(this.kerberosAuthenticationResponseToken); @@ -194,6 +198,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement private String type; + @Nullable private String refreshToken; @Nullable @@ -234,9 +239,9 @@ public final Builder type(String value) { } /** - * Required - API name: {@code refresh_token} + * API name: {@code refresh_token} */ - public final Builder refreshToken(String value) { + public final Builder refreshToken(@Nullable String value) { this.refreshToken = value; return this; } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/sql/QueryRequest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/sql/QueryRequest.java index 2b9d2e54d..5b5c70c3c 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/sql/QueryRequest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/sql/QueryRequest.java @@ -45,7 +45,6 @@ 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; @@ -102,7 +101,7 @@ public class QueryRequest extends RequestBase implements JsonpSerializable { @Nullable private final Time requestTimeout; - private final Map> runtimeMappings; + private final Map runtimeMappings; @Nullable private final String timeZone; @@ -284,7 +283,7 @@ public final Time requestTimeout() { *

* API name: {@code runtime_mappings} */ - public final Map> runtimeMappings() { + public final Map runtimeMappings() { return this.runtimeMappings; } @@ -396,16 +395,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); - for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { + for (Map.Entry item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); - generator.writeStartArray(); - if (item0.getValue() != null) { - for (RuntimeField item1 : item0.getValue()) { - item1.serialize(generator, mapper); - - } - } - generator.writeEnd(); + item0.getValue().serialize(generator, mapper); } generator.writeEnd(); @@ -474,7 +466,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement private Time requestTimeout; @Nullable - private Map> runtimeMappings; + private Map runtimeMappings; @Nullable private String timeZone; @@ -681,7 +673,7 @@ public final Builder requestTimeout(Function> *

* Adds all entries of map to runtimeMappings. */ - public final Builder runtimeMappings(Map> map) { + public final Builder runtimeMappings(Map map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } @@ -694,11 +686,24 @@ public final Builder runtimeMappings(Map> map) { *

* Adds an entry to runtimeMappings. */ - public final Builder runtimeMappings(String key, List value) { + public final Builder runtimeMappings(String key, RuntimeField value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } + /** + * Defines one or more runtime fields in the search request. These fields take + * precedence over mapped fields with the same name. + *

+ * API name: {@code runtime_mappings} + *

+ * Adds an entry to runtimeMappings using a builder lambda. + */ + public final Builder runtimeMappings(String key, + Function> fn) { + return runtimeMappings(key, fn.apply(new RuntimeField.Builder()).build()); + } + /** * Time-zone in ISO 8601 used for executing the query on the server. More * information available here. @@ -774,8 +779,8 @@ protected static void setupQueryRequestDeserializer(ObjectDeserializer> runtimeMappings; + private final Map runtimeMappings; // --------------------------------------------------------------------------------------------- @@ -108,7 +108,7 @@ public final Query query() { *

* API name: {@code runtime_mappings} */ - public final Map> runtimeMappings() { + public final Map runtimeMappings() { return this.runtimeMappings; } @@ -141,16 +141,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); - for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { + for (Map.Entry item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); - generator.writeStartArray(); - if (item0.getValue() != null) { - for (RuntimeField item1 : item0.getValue()) { - item1.serialize(generator, mapper); - - } - } - generator.writeEnd(); + item0.getValue().serialize(generator, mapper); } generator.writeEnd(); @@ -177,7 +170,7 @@ public static class Builder extends WithJsonObjectBuilderBase implement private Query query; @Nullable - private Map> runtimeMappings; + private Map runtimeMappings; /** * Required - The source indices for the transform. It can be a single index, an @@ -249,7 +242,7 @@ public final Builder query(Function> fn) { *

* Adds all entries of map to runtimeMappings. */ - public final Builder runtimeMappings(Map> map) { + public final Builder runtimeMappings(Map map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } @@ -263,11 +256,25 @@ public final Builder runtimeMappings(Map> map) { *

* Adds an entry to runtimeMappings. */ - public final Builder runtimeMappings(String key, List value) { + public final Builder runtimeMappings(String key, RuntimeField value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } + /** + * Definitions of search-time runtime fields that can be used by the transform. + * For search runtime fields all data nodes, including remote nodes, must be + * 7.12 or later. + *

+ * API name: {@code runtime_mappings} + *

+ * Adds an entry to runtimeMappings using a builder lambda. + */ + public final Builder runtimeMappings(String key, + Function> fn) { + return runtimeMappings(key, fn.apply(new RuntimeField.Builder()).build()); + } + @Override protected Builder self() { return this; @@ -298,8 +305,8 @@ protected static void setupSourceDeserializer(ObjectDeserializer op.add(Builder::index, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "index"); op.add(Builder::query, Query._DESERIALIZER, "query"); - op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( - JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); + op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer(RuntimeField._DESERIALIZER), + "runtime_mappings"); } 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 4edf3de9a..9285aebbf 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 @@ -26,6 +26,7 @@ import co.elastic.clients.json.jsonb.JsonbJsonpMapper; import co.elastic.clients.transport.ElasticsearchTransport; import co.elastic.clients.transport.JsonEndpoint; +import co.elastic.clients.transport.Version; import co.elastic.clients.transport.endpoints.DelegatingJsonEndpoint; import co.elastic.clients.transport.rest_client.RestClientTransport; import org.apache.http.HttpHost; @@ -34,12 +35,16 @@ import org.apache.http.impl.client.BasicCredentialsProvider; import org.elasticsearch.client.RestClient; import org.testcontainers.elasticsearch.ElasticsearchContainer; +import org.testcontainers.images.builder.ImageFromDockerfile; +import org.testcontainers.utility.DockerImageName; +import javax.net.ssl.SSLContext; import java.io.IOException; import java.time.Duration; public class ElasticsearchTestServer implements AutoCloseable { + private final String[] plugins; private volatile ElasticsearchContainer container; private int port; private final JsonpMapper mapper = new JsonbJsonpMapper(); @@ -53,7 +58,7 @@ public static synchronized ElasticsearchTestServer global() { if (global == null) { System.out.println("Starting global ES test server."); global = new ElasticsearchTestServer(); - global.setup(); + global.start(); Runtime.getRuntime().addShutdownHook(new Thread(() -> { System.out.println("Stopping global ES test server."); global.close(); @@ -62,24 +67,62 @@ public static synchronized ElasticsearchTestServer global() { return global; } - private synchronized void setup() { - container = new ElasticsearchContainer("docker.elastic.co/elasticsearch/elasticsearch:7.17.4") + public ElasticsearchTestServer(String... plugins) { + this.plugins = plugins; + } + + public synchronized ElasticsearchTestServer start() { + Version version = Version.VERSION.major() < 8 ? new Version(7,17,5,false) : new Version(8,3,3,false); + + // Note we could use version.major() + "." + version.minor() + "-SNAPSHOT" but plugins won't install on a snapshot version + String esImage = "docker.elastic.co/elasticsearch/elasticsearch:" + version; + + DockerImageName image; + if (plugins.length == 0) { + image = DockerImageName.parse(esImage); + } else { + String esWithPluginsImage = new ImageFromDockerfile() + .withDockerfileFromBuilder(b -> { + b.from(esImage); + for (String plugin : plugins) { + b.run("/usr/share/elasticsearch/bin/elasticsearch-plugin", "install", plugin); + } + } + ).get(); + + image = DockerImageName + .parse(esWithPluginsImage) + .asCompatibleSubstituteFor("docker.elastic.co/elasticsearch/elasticsearch"); + } + + container = new ElasticsearchContainer(image) .withEnv("ES_JAVA_OPTS", "-Xms256m -Xmx256m") .withEnv("path.repo", "/tmp") // for snapshots .withStartupTimeout(Duration.ofSeconds(30)) .withPassword("changeme"); container.start(); + port = container.getMappedPort(9200); + boolean useTLS = version.major() >= 8; + HttpHost host = new HttpHost("localhost", port, useTLS ? "https": "http"); + + SSLContext sslContext = useTLS ? container.createSslContextFromCa() : null; + BasicCredentialsProvider credsProv = new BasicCredentialsProvider(); credsProv.setCredentials( AuthScope.ANY, new UsernamePasswordCredentials("elastic", "changeme") ); - restClient = RestClient.builder(new HttpHost("localhost", port)) - .setHttpClientConfigCallback(hc -> hc.setDefaultCredentialsProvider(credsProv)) + restClient = RestClient.builder(host) + .setHttpClientConfigCallback(hc -> hc + .setDefaultCredentialsProvider(credsProv) + .setSSLContext(sslContext) + ) .build(); transport = new RestClientTransport(restClient, mapper); client = new ElasticsearchClient(transport); + + return this; } /** 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 6ae3c6227..54f9727be 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 @@ -19,13 +19,19 @@ package co.elastic.clients.elasticsearch.spec_issues; +import co.elastic.clients.documentation.usage.Product; 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.Script; import co.elastic.clients.elasticsearch._types.analysis.LimitTokenCountTokenFilter; +import co.elastic.clients.elasticsearch._types.mapping.Property; +import co.elastic.clients.elasticsearch._types.mapping.RuntimeField; +import co.elastic.clients.elasticsearch._types.mapping.RuntimeFieldType; 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.core.search.Suggester; import co.elastic.clients.elasticsearch.indices.CreateIndexRequest; import co.elastic.clients.elasticsearch.indices.GetFieldMappingRequest; import co.elastic.clients.elasticsearch.indices.GetFieldMappingResponse; @@ -75,11 +81,40 @@ public void i0201_restoreResponse() throws Exception { RestoreResponse restoreResponse = fromJson("{\"acknowledged\":true}", RestoreResponse.class); } + @Test + public void i0298_runtimeMappings() throws Exception { + ElasticsearchClient client = ElasticsearchTestServer.global().client(); + + String index = "i0298"; + + Product p = new Product("p1", "p2", 42.0); + + client.index(ir -> ir + .index(index) + .document(p)); + + client.indices().flush(f -> f.index(index)); + + RuntimeField runtimeField = RuntimeField.of(rf -> rf + .type(RuntimeFieldType.Double) + .script(Script.of(s -> s + .inline(i -> i. + source("emit(doc['price'].value * 1.19)") + ) + )) + ); + + client.search(sr -> sr + .index(index) + .runtimeMappings("priceWithTax", runtimeField), // NOTE: the builder accepts only lists here + Product.class); + } + @Test public void i0297_mappingSettings() { CreateIndexRequest request = CreateIndexRequest.of(r -> r - .index("name") + .index("i0297") .settings(s -> s // This is "mapping" and not "mappings" .mapping(m -> m.totalFields(totalFields -> totalFields.limit(1001))) @@ -118,11 +153,56 @@ public void i0295_mappingSettings() { "}"; CreateIndexRequest request = CreateIndexRequest.of(r -> r - .index("name") + .index("i0295") .withJson(new StringReader(json)) ); } + @Test + public void i0254_suggesterTest() throws Exception { + new Suggester.Builder().suggesters("song-suggest", s -> s.completion(c->c.field("suggest"))).build(); + } + + @Test + public void i0249_variantKind() throws Exception { + try (ElasticsearchTestServer server = new ElasticsearchTestServer("analysis-icu").start()) { + + ElasticsearchClient esClient = server.client(); + + esClient.indices().create(r -> r + .index("i0249") + .withJson(new StringReader("{\n" + + " \"mappings\": {\n" + + " \"properties\": {\n" + + " \"name\": { \n" + + " \"type\": \"text\",\n" + + " \"fields\": {\n" + + " \"sort\": { \n" + + " \"type\": \"icu_collation_keyword\",\n" + + " \"index\": false,\n" + + " \"language\": \"de\",\n" + + " \"country\": \"DE\",\n" + + " \"variant\": \"@collation=phonebook\"\n" + + " }\n" + + " }\n" + + " }\n" + + " }\n" + + " }\n" + + "}\n")) + ); + + GetFieldMappingResponse fm = esClient.indices().getFieldMapping(b -> b + .index("i0249") + .fields("*") + ); + + Property property = fm.get("i0249").mappings().get("name").mapping().get("name").text().fields().get("sort"); + + assertTrue(property._isCustom()); + assertEquals("icu_collation_keyword", property._customKind()); + } + } + @Test public void i0199_consumeAllTokensOptional() { // https://github.com/elastic/elasticsearch-java/issues/199