diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e72f23eea..40b77ec7b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased 2.x] ### Added +- Added support for `KnnVectorProperty`'s `compression_level`, `data_type`, `mode` & `space_type` properties ([#1255](https://github.com/opensearch-project/opensearch-java/pull/1255)) ### Dependencies - Bumps `org.apache.httpcomponents.core5:httpcore5-h2` from 5.3 to 5.3.1 @@ -14,6 +15,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Removed ### Fixed +- Fixed `UndeployModelResponse` deserialization ([#1257](https://github.com/opensearch-project/opensearch-java/pull/1257)) ### Security diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ErrorCause.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ErrorCause.java index 36a0c74b71..912a69c5c9 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ErrorCause.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/ErrorCause.java @@ -108,7 +108,7 @@ public final ErrorCause causedBy() { } /** - * A human-readable explanation of the error, in english + * A human-readable explanation of the error, in English. *

* API name: {@code reason} *

@@ -127,7 +127,7 @@ public final List rootCause() { } /** - * The server stack trace. Present only if the `error_trace=true` parameter was sent with the request. + * The server stack trace, present only if the error_trace=true parameter was sent with the request. *

* API name: {@code stack_trace} *

@@ -146,7 +146,7 @@ public final List suppressed() { } /** - * Required - The type of error + * Required - The type of error. *

* API name: {@code type} *

@@ -157,7 +157,7 @@ public final String type() { } /** - * Additional details about the error. + * Any additional information about the error. */ @Nonnull public final Map metadata() { @@ -252,7 +252,7 @@ public final Builder causedBy(Function * API name: {@code reason} *

@@ -298,7 +298,7 @@ public final Builder rootCause(Functionerror_trace=true parameter was sent with the request. *

* API name: {@code stack_trace} *

@@ -344,7 +344,7 @@ public final Builder suppressed(Function * API name: {@code type} *

@@ -355,7 +355,7 @@ public final Builder type(String value) { } /** - * Additional details about the error. + * Any additional information about the error. * *

* Adds all elements of map to metadata. @@ -367,7 +367,7 @@ public final Builder metadata(Map map) { } /** - * Additional details about the error. + * Any additional information about the error. * *

* Adds an entry to metadata. @@ -415,6 +415,7 @@ protected static void setupErrorCauseDeserializer(ObjectDeserializer> void setupWriteRes op.add(AbstractBuilder::version, JsonpDeserializer.longDeserializer(), "_version"); } + @Override public int hashCode() { int result = 17; result = 31 * result + Objects.hashCode(this.forcedRefresh); @@ -301,6 +302,7 @@ public int hashCode() { return result; } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || this.getClass() != o.getClass()) return false; diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/CorePropertyBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/CorePropertyBase.java similarity index 79% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/CorePropertyBase.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/CorePropertyBase.java index cc14e499e4..062d2fb80a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/CorePropertyBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/CorePropertyBase.java @@ -30,10 +30,17 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; import jakarta.json.stream.JsonGenerator; import java.util.List; +import java.util.Objects; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -42,7 +49,10 @@ // typedef: _types.mapping.CorePropertyBase +@Generated("org.opensearch.client.codegen.CodeGenerator") public abstract class CorePropertyBase extends PropertyBase { + + @Nonnull private final List copyTo; @Nullable @@ -55,16 +65,15 @@ public abstract class CorePropertyBase extends PropertyBase { protected CorePropertyBase(AbstractBuilder builder) { super(builder); - this.copyTo = ApiTypeHelper.unmodifiable(builder.copyTo); this.similarity = builder.similarity; this.store = builder.store; - } /** * API name: {@code copy_to} */ + @Nonnull public final List copyTo() { return this.copyTo; } @@ -86,46 +95,44 @@ public final Boolean store() { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - super.serializeInternal(generator, mapper); if (ApiTypeHelper.isDefined(this.copyTo)) { generator.writeKey("copy_to"); generator.writeStartArray(); for (String item0 : this.copyTo) { generator.write(item0); - } generator.writeEnd(); - } + if (this.similarity != null) { generator.writeKey("similarity"); generator.write(this.similarity); - } + if (this.store != null) { generator.writeKey("store"); generator.write(this.store); - } - } + // --------------------------------------------------------------------------------------------- + protected abstract static class AbstractBuilder> extends PropertyBase.AbstractBuilder< BuilderT> { @Nullable private List copyTo; - @Nullable private String similarity; - @Nullable private Boolean store; /** * API name: {@code copy_to} + * *

* Adds all elements of list to copyTo. + *

*/ public final BuilderT copyTo(List list) { this.copyTo = _listAddAll(this.copyTo, list); @@ -134,8 +141,10 @@ public final BuilderT copyTo(List list) { /** * API name: {@code copy_to} + * *

* Adds one or more values to copyTo. + *

*/ public final BuilderT copyTo(String value, String... values) { this.copyTo = _listAdd(this.copyTo, value, values); @@ -161,12 +170,33 @@ public final BuilderT store(@Nullable Boolean value) { } // --------------------------------------------------------------------------------------------- + protected static > void setupCorePropertyBaseDeserializer(ObjectDeserializer op) { - PropertyBase.setupPropertyBaseDeserializer(op); + setupPropertyBaseDeserializer(op); op.add(AbstractBuilder::copyTo, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "copy_to"); op.add(AbstractBuilder::similarity, JsonpDeserializer.stringDeserializer(), "similarity"); op.add(AbstractBuilder::store, JsonpDeserializer.booleanDeserializer(), "store"); + } + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + Objects.hashCode(this.copyTo); + result = 31 * result + Objects.hashCode(this.similarity); + result = 31 * result + Objects.hashCode(this.store); + return result; } + @Override + public boolean equals(Object o) { + if (!super.equals(o)) { + return false; + } + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + CorePropertyBase other = (CorePropertyBase) o; + return Objects.equals(this.copyTo, other.copyTo) + && Objects.equals(this.similarity, other.similarity) + && Objects.equals(this.store, other.store); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/DocValuesPropertyBase.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/DocValuesPropertyBase.java similarity index 76% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/DocValuesPropertyBase.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/DocValuesPropertyBase.java index 8ffe566ebb..a5b51d9677 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/DocValuesPropertyBase.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/DocValuesPropertyBase.java @@ -30,9 +30,15 @@ * GitHub history for details. */ +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import javax.annotation.Generated; import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -40,7 +46,9 @@ // typedef: _types.mapping.DocValuesPropertyBase +@Generated("org.opensearch.client.codegen.CodeGenerator") public abstract class DocValuesPropertyBase extends CorePropertyBase { + @Nullable private final Boolean docValues; @@ -48,9 +56,7 @@ public abstract class DocValuesPropertyBase extends CorePropertyBase { protected DocValuesPropertyBase(AbstractBuilder builder) { super(builder); - this.docValues = builder.docValues; - } /** @@ -62,16 +68,15 @@ public final Boolean docValues() { } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - super.serializeInternal(generator, mapper); if (this.docValues != null) { generator.writeKey("doc_values"); generator.write(this.docValues); - } - } + // --------------------------------------------------------------------------------------------- + protected abstract static class AbstractBuilder> extends CorePropertyBase.AbstractBuilder< BuilderT> { @Nullable @@ -88,12 +93,29 @@ public final BuilderT docValues(@Nullable Boolean value) { } // --------------------------------------------------------------------------------------------- + protected static > void setupDocValuesPropertyBaseDeserializer( ObjectDeserializer op ) { setupCorePropertyBaseDeserializer(op); op.add(AbstractBuilder::docValues, JsonpDeserializer.booleanDeserializer(), "doc_values"); + } + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + Objects.hashCode(this.docValues); + return result; } + @Override + public boolean equals(Object o) { + if (!super.equals(o)) { + return false; + } + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + DocValuesPropertyBase other = (DocValuesPropertyBase) o; + return Objects.equals(this.docValues, other.docValues); + } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/KnnVectorMethod.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/KnnVectorMethod.java similarity index 68% rename from java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/KnnVectorMethod.java rename to java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/KnnVectorMethod.java index b9077a43da..da8f7400c0 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/KnnVectorMethod.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/KnnVectorMethod.java @@ -6,11 +6,42 @@ * compatible open source license. */ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + package org.opensearch.client.opensearch._types.mapping; import jakarta.json.stream.JsonGenerator; import java.util.Map; +import java.util.Objects; import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opensearch.client.json.JsonData; import org.opensearch.client.json.JsonpDeserializable; @@ -26,68 +57,167 @@ // typedef: _types.mapping.KnnVectorMethod @JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") public class KnnVectorMethod implements PlainJsonSerializable { + + @Nullable + private final String engine; + + @Nonnull + private final String name; + + @Nonnull + private final Map parameters; + + @Nullable + private final String spaceType; + + // --------------------------------------------------------------------------------------------- + + private KnnVectorMethod(Builder builder) { + this.engine = builder.engine; + this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); + this.parameters = ApiTypeHelper.unmodifiable(builder.parameters); + this.spaceType = builder.spaceType; + } + + public static KnnVectorMethod of(Function> fn) { + return fn.apply(new Builder()).build(); + } + /** - * Builder for {@link KnnVectorMethod}. + * API name: {@code engine} */ + @Nullable + public final String engine() { + return this.engine; + } - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private String name; + /** + * Required - API name: {@code name} + */ + @Nonnull + public final String name() { + return this.name; + } - @Nullable - private String spaceType; + /** + * API name: {@code parameters} + */ + @Nonnull + public final Map parameters() { + return this.parameters; + } + + /** + * API name: {@code space_type} + */ + @Nullable + public final String spaceType() { + return this.spaceType; + } + + /** + * Serialize this object to JSON. + */ + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + if (this.engine != null) { + generator.writeKey("engine"); + generator.write(this.engine); + } + + generator.writeKey("name"); + generator.write(this.name); + + if (ApiTypeHelper.isDefined(this.parameters)) { + generator.writeKey("parameters"); + generator.writeStartObject(); + for (Map.Entry item0 : this.parameters.entrySet()) { + generator.writeKey(item0.getKey()); + item0.getValue().serialize(generator, mapper); + } + generator.writeEnd(); + } + + if (this.spaceType != null) { + generator.writeKey("space_type"); + generator.write(this.spaceType); + } + } + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link KnnVectorMethod}. + */ + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { @Nullable private String engine; - + private String name; @Nullable private Map parameters; + @Nullable + private String spaceType; /** - * Required - API name: {@code name} + * API name: {@code engine} */ - public final Builder name(String value) { - this.name = value; + public final Builder engine(@Nullable String value) { + this.engine = value; return this; } /** - * API name: {@code space_type} + * Required - API name: {@code name} */ - public final Builder spaceType(@Nullable String value) { - this.spaceType = value; + public final Builder name(String value) { + this.name = value; return this; } /** - * API name: {@code engine} + * API name: {@code parameters} + * + *

+ * Adds all elements of map to parameters. + *

*/ - public final Builder engine(@Nullable String value) { - this.engine = value; + public final Builder parameters(Map map) { + this.parameters = _mapPutAll(this.parameters, map); return this; } /** * API name: {@code parameters} + * + *

+ * Adds an entry to parameters. + *

*/ - public final Builder parameters(@Nullable Map map) { - this.parameters = _mapPutAll(this.parameters, map); + public final Builder parameters(String key, JsonData value) { + this.parameters = _mapPut(this.parameters, key, value); return this; } /** - * API name: {@code parameters} + * API name: {@code space_type} */ - public final Builder parameters(String key, JsonData value) { - this.parameters = _mapPut(this.parameters, key, value); + public final Builder spaceType(@Nullable String value) { + this.spaceType = value; return this; } /** * Builds a {@link KnnVectorMethod}. * - * @throws NullPointerException - * if some of the required fields are null. + * @throws NullPointerException if some of the required fields are null. */ public KnnVectorMethod build() { _checkSingleUse(); @@ -96,6 +226,8 @@ public KnnVectorMethod build() { } } + // --------------------------------------------------------------------------------------------- + /** * Json deserializer for {@link KnnVectorMethod} */ @@ -104,110 +236,31 @@ public KnnVectorMethod build() { KnnVectorMethod::setupKnnVectorMethodDeserializer ); - public static KnnVectorMethod of(Function> fn) { - return fn.apply(new Builder()).build(); - } - protected static void setupKnnVectorMethodDeserializer(ObjectDeserializer op) { - - op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); - op.add(Builder::spaceType, JsonpDeserializer.stringDeserializer(), "space_type"); op.add(Builder::engine, JsonpDeserializer.stringDeserializer(), "engine"); + op.add(Builder::name, JsonpDeserializer.stringDeserializer(), "name"); op.add(Builder::parameters, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "parameters"); - - } - - // --------------------------------------------------------------------------------------------- - - private final String name; - - @Nullable - private final String spaceType; - - @Nullable - private final String engine; - - @Nullable - private final Map parameters; - - private KnnVectorMethod(Builder builder) { - - this.name = ApiTypeHelper.requireNonNull(builder.name, this, "name"); - this.spaceType = builder.spaceType; - this.engine = builder.engine; - this.parameters = builder.parameters; - - } - - /** - * Required - API name: {@code name} - */ - public final String name() { - return this.name; - } - - /** - * API name: {@code space_type} - */ - @Nullable - public final String spaceType() { - return this.spaceType; + op.add(Builder::spaceType, JsonpDeserializer.stringDeserializer(), "space_type"); } - /** - * API name: {@code engine} - */ - @Nullable - public final String engine() { - return this.engine; + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(this.engine); + result = 31 * result + this.name.hashCode(); + result = 31 * result + Objects.hashCode(this.parameters); + result = 31 * result + Objects.hashCode(this.spaceType); + return result; } - // --------------------------------------------------------------------------------------------- - - /** - * API name: {@code parameters} - */ - @Nullable - public final Map parameters() { - return this.parameters; + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + KnnVectorMethod other = (KnnVectorMethod) o; + return Objects.equals(this.engine, other.engine) + && this.name.equals(other.name) + && Objects.equals(this.parameters, other.parameters) + && Objects.equals(this.spaceType, other.spaceType); } - - // --------------------------------------------------------------------------------------------- - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("name"); - generator.write(this.name); - - if (this.spaceType != null) { - generator.writeKey("space_type"); - generator.write(this.spaceType); - } - - if (this.engine != null) { - generator.writeKey("engine"); - generator.write(this.engine); - } - - if (this.parameters != null) { - generator.writeKey("parameters"); - generator.writeStartObject(); - for (Map.Entry item0 : this.parameters.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - generator.writeEnd(); - } - - } - } diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/KnnVectorProperty.java b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/KnnVectorProperty.java new file mode 100644 index 0000000000..54ed487dde --- /dev/null +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/_types/mapping/KnnVectorProperty.java @@ -0,0 +1,347 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +//---------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------- + +package org.opensearch.client.opensearch._types.mapping; + +import jakarta.json.stream.JsonGenerator; +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Generated; +import javax.annotation.Nullable; +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.ObjectBuilder; + +// typedef: _types.mapping.KnnVectorProperty + +@JsonpDeserializable +@Generated("org.opensearch.client.codegen.CodeGenerator") +public class KnnVectorProperty extends DocValuesPropertyBase implements PropertyVariant { + + @Nullable + private final String compressionLevel; + + @Nullable + private final String dataType; + + private final int dimension; + + @Nullable + private final KnnVectorMethod method; + + @Nullable + private final String mode; + + @Nullable + private final String modelId; + + @Nullable + private final String spaceType; + + // --------------------------------------------------------------------------------------------- + + private KnnVectorProperty(Builder builder) { + super(builder); + this.compressionLevel = builder.compressionLevel; + this.dataType = builder.dataType; + this.dimension = ApiTypeHelper.requireNonNull(builder.dimension, this, "dimension"); + this.method = builder.method; + this.mode = builder.mode; + this.modelId = builder.modelId; + this.spaceType = builder.spaceType; + } + + public static KnnVectorProperty of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * {@link Property} variant kind. + */ + @Override + public Property.Kind _propertyKind() { + return Property.Kind.KnnVector; + } + + /** + * API name: {@code compression_level} + */ + @Nullable + public final String compressionLevel() { + return this.compressionLevel; + } + + /** + * API name: {@code data_type} + */ + @Nullable + public final String dataType() { + return this.dataType; + } + + /** + * Required - API name: {@code dimension} + */ + public final int dimension() { + return this.dimension; + } + + /** + * API name: {@code method} + */ + @Nullable + public final KnnVectorMethod method() { + return this.method; + } + + /** + * API name: {@code mode} + */ + @Nullable + public final String mode() { + return this.mode; + } + + /** + * API name: {@code model_id} + */ + @Nullable + public final String modelId() { + return this.modelId; + } + + /** + * API name: {@code space_type} + */ + @Nullable + public final String spaceType() { + return this.spaceType; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + generator.write("type", "knn_vector"); + super.serializeInternal(generator, mapper); + if (this.compressionLevel != null) { + generator.writeKey("compression_level"); + generator.write(this.compressionLevel); + } + + if (this.dataType != null) { + generator.writeKey("data_type"); + generator.write(this.dataType); + } + + generator.writeKey("dimension"); + generator.write(this.dimension); + + if (this.method != null) { + generator.writeKey("method"); + this.method.serialize(generator, mapper); + } + + if (this.mode != null) { + generator.writeKey("mode"); + generator.write(this.mode); + } + + if (this.modelId != null) { + generator.writeKey("model_id"); + generator.write(this.modelId); + } + + if (this.spaceType != null) { + generator.writeKey("space_type"); + generator.write(this.spaceType); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link KnnVectorProperty}. + */ + public static class Builder extends DocValuesPropertyBase.AbstractBuilder implements ObjectBuilder { + @Nullable + private String compressionLevel; + @Nullable + private String dataType; + private Integer dimension; + @Nullable + private KnnVectorMethod method; + @Nullable + private String mode; + @Nullable + private String modelId; + @Nullable + private String spaceType; + + /** + * API name: {@code compression_level} + */ + public final Builder compressionLevel(@Nullable String value) { + this.compressionLevel = value; + return this; + } + + /** + * API name: {@code data_type} + */ + public final Builder dataType(@Nullable String value) { + this.dataType = value; + return this; + } + + /** + * Required - API name: {@code dimension} + */ + public final Builder dimension(int value) { + this.dimension = value; + return this; + } + + /** + * API name: {@code method} + */ + public final Builder method(@Nullable KnnVectorMethod value) { + this.method = value; + return this; + } + + /** + * API name: {@code method} + */ + public final Builder method(Function> fn) { + return method(fn.apply(new KnnVectorMethod.Builder()).build()); + } + + /** + * API name: {@code mode} + */ + public final Builder mode(@Nullable String value) { + this.mode = value; + return this; + } + + /** + * API name: {@code model_id} + */ + public final Builder modelId(@Nullable String value) { + this.modelId = value; + return this; + } + + /** + * API name: {@code space_type} + */ + public final Builder spaceType(@Nullable String value) { + this.spaceType = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link KnnVectorProperty}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public KnnVectorProperty build() { + _checkSingleUse(); + + return new KnnVectorProperty(this); + } + } + + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link KnnVectorProperty} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + KnnVectorProperty::setupKnnVectorPropertyDeserializer + ); + + protected static void setupKnnVectorPropertyDeserializer(ObjectDeserializer op) { + setupDocValuesPropertyBaseDeserializer(op); + op.add(Builder::compressionLevel, JsonpDeserializer.stringDeserializer(), "compression_level"); + op.add(Builder::dataType, JsonpDeserializer.stringDeserializer(), "data_type"); + op.add(Builder::dimension, JsonpDeserializer.integerDeserializer(), "dimension"); + op.add(Builder::method, KnnVectorMethod._DESERIALIZER, "method"); + op.add(Builder::mode, JsonpDeserializer.stringDeserializer(), "mode"); + op.add(Builder::modelId, JsonpDeserializer.stringDeserializer(), "model_id"); + op.add(Builder::spaceType, JsonpDeserializer.stringDeserializer(), "space_type"); + + op.ignore("type"); + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + Objects.hashCode(this.compressionLevel); + result = 31 * result + Objects.hashCode(this.dataType); + result = 31 * result + Integer.hashCode(this.dimension); + result = 31 * result + Objects.hashCode(this.method); + result = 31 * result + Objects.hashCode(this.mode); + result = 31 * result + Objects.hashCode(this.modelId); + result = 31 * result + Objects.hashCode(this.spaceType); + return result; + } + + @Override + public boolean equals(Object o) { + if (!super.equals(o)) { + return false; + } + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + KnnVectorProperty other = (KnnVectorProperty) o; + return Objects.equals(this.compressionLevel, other.compressionLevel) + && Objects.equals(this.dataType, other.dataType) + && this.dimension == other.dimension + && Objects.equals(this.method, other.method) + && Objects.equals(this.mode, other.mode) + && Objects.equals(this.modelId, other.modelId) + && Objects.equals(this.spaceType, other.spaceType); + } +} diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Action.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Action.java index 38e6fa54af..36c3693a44 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Action.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Action.java @@ -288,6 +288,7 @@ protected static void setupActionDeserializer(ObjectDeserializer op.add(Builder::url, JsonpDeserializer.stringDeserializer(), "url"); } + @Override public int hashCode() { int result = 17; result = 31 * result + Objects.hashCode(this.actionType); @@ -300,6 +301,7 @@ public int hashCode() { return result; } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || this.getClass() != o.getClass()) return false; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/ClientConfig.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/ClientConfig.java index bd03b5ec22..9e1be3d3c8 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/ClientConfig.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/ClientConfig.java @@ -281,6 +281,7 @@ protected static void setupClientConfigDeserializer(ObjectDeserializer implements ObjectBuilder { + @Override protected Builder self() { return this; @@ -71,14 +72,16 @@ public DeleteAgentResponse build() { ); protected static void setupDeleteAgentResponseDeserializer(ObjectDeserializer op) { - WriteResponseBase.setupWriteResponseBaseDeserializer(op); + setupWriteResponseBaseDeserializer(op); } + @Override public int hashCode() { int result = super.hashCode(); return result; } + @Override public boolean equals(Object o) { if (!super.equals(o)) { return false; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteConnectorRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteConnectorRequest.java index eba26ddd93..67dc24abbf 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteConnectorRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteConnectorRequest.java @@ -102,12 +102,14 @@ public DeleteConnectorRequest build() { DeleteConnectorResponse._DESERIALIZER ); + @Override public int hashCode() { int result = 17; result = 31 * result + this.connectorId.hashCode(); return result; } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || this.getClass() != o.getClass()) return false; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteConnectorResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteConnectorResponse.java index 8191f76081..6b5b4505c1 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteConnectorResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteConnectorResponse.java @@ -43,6 +43,7 @@ public static DeleteConnectorResponse of(Function implements ObjectBuilder { + @Override protected Builder self() { return this; @@ -71,14 +72,16 @@ public DeleteConnectorResponse build() { ); protected static void setupDeleteConnectorResponseDeserializer(ObjectDeserializer op) { - WriteResponseBase.setupWriteResponseBaseDeserializer(op); + setupWriteResponseBaseDeserializer(op); } + @Override public int hashCode() { int result = super.hashCode(); return result; } + @Override public boolean equals(Object o) { if (!super.equals(o)) { return false; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupRequest.java index e62ba1c38a..4d4bf9975e 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupRequest.java @@ -102,12 +102,14 @@ public DeleteModelGroupRequest build() { DeleteModelGroupResponse._DESERIALIZER ); + @Override public int hashCode() { int result = 17; result = 31 * result + this.modelGroupId.hashCode(); return result; } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || this.getClass() != o.getClass()) return false; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupResponse.java index 77595ef8a3..668e866e41 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelGroupResponse.java @@ -43,6 +43,7 @@ public static DeleteModelGroupResponse of(Function implements ObjectBuilder { + @Override protected Builder self() { return this; @@ -71,14 +72,16 @@ public DeleteModelGroupResponse build() { ); protected static void setupDeleteModelGroupResponseDeserializer(ObjectDeserializer op) { - WriteResponseBase.setupWriteResponseBaseDeserializer(op); + setupWriteResponseBaseDeserializer(op); } + @Override public int hashCode() { int result = super.hashCode(); return result; } + @Override public boolean equals(Object o) { if (!super.equals(o)) { return false; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelRequest.java index 70bbbde1ea..21c8977ae0 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelRequest.java @@ -102,12 +102,14 @@ public DeleteModelRequest build() { DeleteModelResponse._DESERIALIZER ); + @Override public int hashCode() { int result = 17; result = 31 * result + this.modelId.hashCode(); return result; } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || this.getClass() != o.getClass()) return false; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelResponse.java index 45e9cf97ef..b287fe2481 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteModelResponse.java @@ -43,6 +43,7 @@ public static DeleteModelResponse of(Function implements ObjectBuilder { + @Override protected Builder self() { return this; @@ -71,14 +72,16 @@ public DeleteModelResponse build() { ); protected static void setupDeleteModelResponseDeserializer(ObjectDeserializer op) { - WriteResponseBase.setupWriteResponseBaseDeserializer(op); + setupWriteResponseBaseDeserializer(op); } + @Override public int hashCode() { int result = super.hashCode(); return result; } + @Override public boolean equals(Object o) { if (!super.equals(o)) { return false; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskRequest.java index 24cc8996a9..7ff50996a8 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskRequest.java @@ -102,12 +102,14 @@ public DeleteTaskRequest build() { DeleteTaskResponse._DESERIALIZER ); + @Override public int hashCode() { int result = 17; result = 31 * result + this.taskId.hashCode(); return result; } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || this.getClass() != o.getClass()) return false; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskResponse.java index 21d872184a..36cd9a2740 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeleteTaskResponse.java @@ -43,6 +43,7 @@ public static DeleteTaskResponse of(Function implements ObjectBuilder { + @Override protected Builder self() { return this; @@ -71,14 +72,16 @@ public DeleteTaskResponse build() { ); protected static void setupDeleteTaskResponseDeserializer(ObjectDeserializer op) { - WriteResponseBase.setupWriteResponseBaseDeserializer(op); + setupWriteResponseBaseDeserializer(op); } + @Override public int hashCode() { int result = super.hashCode(); return result; } + @Override public boolean equals(Object o) { if (!super.equals(o)) { return false; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelRequest.java index bf5ec056be..0b41a42145 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelRequest.java @@ -103,12 +103,14 @@ public DeployModelRequest build() { DeployModelResponse._DESERIALIZER ); + @Override public int hashCode() { int result = 17; result = 31 * result + this.modelId.hashCode(); return result; } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || this.getClass() != o.getClass()) return false; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelResponse.java index 65469f5a2d..b9d2053907 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/DeployModelResponse.java @@ -165,6 +165,7 @@ protected static void setupDeployModelResponseDeserializer(ObjectDeserializer op) { op.add(Builder::parameters, JsonpDeserializer.stringMapDeserializer(JsonData._DESERIALIZER), "parameters"); } + @Override public int hashCode() { int result = 17; result = 31 * result + Objects.hashCode(this.modelId); @@ -170,6 +171,7 @@ public int hashCode() { return result; } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || this.getClass() != o.getClass()) return false; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Memory.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Memory.java index 0660178e13..83bda00de2 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Memory.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/Memory.java @@ -113,12 +113,14 @@ protected static void setupMemoryDeserializer(ObjectDeserializer op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); } + @Override public int hashCode() { int result = 17; result = 31 * result + Objects.hashCode(this.type); return result; } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || this.getClass() != o.getClass()) return false; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsRequest.java index 2c2e560a6d..4e5c31c555 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsRequest.java @@ -397,6 +397,7 @@ protected static void setupRegisterAgentsRequestDeserializer(ObjectDeserializer< RegisterAgentsResponse._DESERIALIZER ); + @Override public int hashCode() { int result = 17; result = 31 * result + Objects.hashCode(this.appType); @@ -410,6 +411,7 @@ public int hashCode() { return result; } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || this.getClass() != o.getClass()) return false; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsResponse.java index b15475a2aa..816fe2cf91 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterAgentsResponse.java @@ -113,12 +113,14 @@ protected static void setupRegisterAgentsResponseDeserializer(ObjectDeserializer op.add(Builder::agentId, JsonpDeserializer.stringDeserializer(), "agent_id"); } + @Override public int hashCode() { int result = 17; result = 31 * result + Objects.hashCode(this.agentId); return result; } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || this.getClass() != o.getClass()) return false; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupRequest.java index e7bc41bb13..fc1b736361 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupRequest.java @@ -301,6 +301,7 @@ protected static void setupRegisterModelGroupRequestDeserializer(ObjectDeseriali RegisterModelGroupResponse._DESERIALIZER ); + @Override public int hashCode() { int result = 17; result = 31 * result + Objects.hashCode(this.accessMode); @@ -311,6 +312,7 @@ public int hashCode() { return result; } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || this.getClass() != o.getClass()) return false; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupResponse.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupResponse.java index ac99154507..3b0faba22c 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupResponse.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelGroupResponse.java @@ -149,6 +149,7 @@ protected static void setupRegisterModelGroupResponseDeserializer(ObjectDeserial op.add(Builder::status, JsonpDeserializer.stringDeserializer(), "status"); } + @Override public int hashCode() { int result = 17; result = 31 * result + this.modelGroupId.hashCode(); @@ -156,6 +157,7 @@ public int hashCode() { return result; } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || this.getClass() != o.getClass()) return false; diff --git a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelRequest.java b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelRequest.java index 5261601622..ac004ddd21 100644 --- a/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelRequest.java +++ b/java-client/src/generated/java/org/opensearch/client/opensearch/ml/RegisterModelRequest.java @@ -271,6 +271,7 @@ protected static void setupRegisterModelRequestDeserializer(ObjectDeserializer nodes; - +public class UndeployModelResponse extends DictionaryResponse { // --------------------------------------------------------------------------------------------- private UndeployModelResponse(Builder builder) { - this.nodes = ApiTypeHelper.unmodifiable(builder.nodes); + super(builder); } public static UndeployModelResponse of(Function> fn) { return fn.apply(new Builder()).build(); } - /** - */ - @Nonnull - public final Map nodes() { - return this.nodes; - } - - /** - * Serialize this object to JSON. - */ - @Override - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - for (Map.Entry item0 : this.nodes.entrySet()) { - generator.writeKey(item0.getKey()); - item0.getValue().serialize(generator, mapper); - } - } - // --------------------------------------------------------------------------------------------- /** * Builder for {@link UndeployModelResponse}. */ - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Nullable - private Map nodes; - - /** - * - *

- * Adds all elements of map to nodes. - *

- */ - public final Builder nodes(Map map) { - this.nodes = _mapPutAll(this.nodes, map); + public static class Builder extends DictionaryResponse.AbstractBuilder + implements + ObjectBuilder { + @Override + protected Builder self() { return this; } - /** - * - *

- * Adds an entry to nodes. - *

- */ - public final Builder nodes(String key, UndeployModelNode value) { - this.nodes = _mapPut(this.nodes, key, value); - return this; - } - - /** - * - *

- * Adds a value to nodes using a builder lambda. - *

- */ - public final Builder nodes(String key, Function> fn) { - return nodes(key, fn.apply(new UndeployModelNode.Builder()).build()); - } - /** * Builds a {@link UndeployModelResponse}. * @@ -121,6 +56,8 @@ public final Builder nodes(String key, Function op) { - op.setUnknownFieldHandler((builder, name, parser, mapper) -> { - if (builder.nodes == null) { - builder.nodes = new HashMap<>(); - } - builder.nodes.put(name, UndeployModelNode._DESERIALIZER.deserialize(parser, mapper)); - }); - } - - public int hashCode() { - int result = 17; - result = 31 * result + Objects.hashCode(this.nodes); - return result; - } - - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || this.getClass() != o.getClass()) return false; - UndeployModelResponse other = (UndeployModelResponse) o; - return Objects.equals(this.nodes, other.nodes); + setupDictionaryResponseDeserializer(op, JsonpDeserializer.stringDeserializer(), UndeployModelNode._DESERIALIZER); } } diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/KnnVectorProperty.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/KnnVectorProperty.java deleted file mode 100644 index 6a1261c5dd..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/KnnVectorProperty.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -package org.opensearch.client.opensearch._types.mapping; - -import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; -import javax.annotation.Nullable; -import org.opensearch.client.json.JsonpDeserializable; -import org.opensearch.client.json.JsonpDeserializer; -import org.opensearch.client.json.JsonpMapper; -import org.opensearch.client.json.ObjectBuilderDeserializer; -import org.opensearch.client.json.ObjectDeserializer; -import org.opensearch.client.util.ApiTypeHelper; -import org.opensearch.client.util.ObjectBuilder; - -// typedef: _types.mapping.KnnVectorProperty - -@JsonpDeserializable -public class KnnVectorProperty extends PropertyBase implements PropertyVariant { - /** - * Builder for {@link KnnVectorProperty}. - */ - - public static class Builder extends PropertyBase.AbstractBuilder implements ObjectBuilder { - private Integer dimension; - - @Nullable - private String modelId; - - @Nullable - private KnnVectorMethod method; - - /** - * Required - API name: {@code dimension} - */ - public final Builder dimension(int value) { - this.dimension = value; - return this; - } - - /** - * API name: {@code model_id} - */ - public final Builder modelId(@Nullable String value) { - this.modelId = value; - return this; - } - - /** - * API name: {@code method} - */ - public final Builder method(@Nullable KnnVectorMethod value) { - this.method = value; - return this; - } - - /** - * API name: {@code method} - */ - public final Builder method(Function> fn) { - return this.method(fn.apply(new KnnVectorMethod.Builder()).build()); - } - - /** - * Builds a {@link KnnVectorProperty}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public KnnVectorProperty build() { - _checkSingleUse(); - - return new KnnVectorProperty(this); - } - - @Override - protected Builder self() { - return this; - } - } - - /** - * Json deserializer for {@link KnnVectorProperty} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( - Builder::new, - KnnVectorProperty::setupKnnVectorPropertyDeserializer - ); - - public static KnnVectorProperty of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - // --------------------------------------------------------------------------------------------- - - protected static void setupKnnVectorPropertyDeserializer(ObjectDeserializer op) { - PropertyBase.setupPropertyBaseDeserializer(op); - op.add(Builder::dimension, JsonpDeserializer.integerDeserializer(), "dimension"); - op.add(Builder::modelId, JsonpDeserializer.stringDeserializer(), "model_id"); - op.add(Builder::method, KnnVectorMethod._DESERIALIZER, "method"); - - op.ignore("type"); - } - - private final int dimension; - - @Nullable - private final String modelId; - - @Nullable - private final KnnVectorMethod method; - - private KnnVectorProperty(Builder builder) { - super(builder); - - this.dimension = ApiTypeHelper.requireNonNull(builder.dimension, this, "dimension"); - this.modelId = builder.modelId; - this.method = builder.method; - - } - - /** - * Property variant kind. - */ - @Override - public Property.Kind _propertyKind() { - return Property.Kind.KnnVector; - } - - /** - * Required - API name: {@code dimension} - */ - public final int dimension() { - return this.dimension; - } - - // --------------------------------------------------------------------------------------------- - - /** - * API name: {@code model_id} - */ - @Nullable - public final String modelId() { - return this.modelId; - } - - // --------------------------------------------------------------------------------------------- - - /** - * API name: {@code method} - */ - @Nullable - public final KnnVectorMethod method() { - return this.method; - } - - @Override - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.write("type", "knn_vector"); - super.serializeInternal(generator, mapper); - generator.writeKey("dimension"); - generator.write(this.dimension); - - if (this.modelId != null) { - - generator.writeKey("model_id"); - generator.write(this.modelId); - - } - - if (this.method != null) { - - generator.writeKey("method"); - this.method.serialize(generator, mapper); - } - - } - -} diff --git a/java-client/src/main/java/org/opensearch/client/transport/endpoints/BooleanEndpoint.java b/java-client/src/main/java/org/opensearch/client/transport/endpoints/BooleanEndpoint.java index a6969671ac..70200eaab4 100644 --- a/java-client/src/main/java/org/opensearch/client/transport/endpoints/BooleanEndpoint.java +++ b/java-client/src/main/java/org/opensearch/client/transport/endpoints/BooleanEndpoint.java @@ -38,6 +38,15 @@ public class BooleanEndpoint extends SimpleEndpoint { + public BooleanEndpoint( + Function method, + Function requestUrl, + Function> queryParameters, + Function> headers + ) { + super(method, requestUrl, queryParameters, headers, false, null); + } + public BooleanEndpoint( String id, Function method, diff --git a/java-client/src/main/java/org/opensearch/client/transport/endpoints/DictionaryResponse.java b/java-client/src/main/java/org/opensearch/client/transport/endpoints/DictionaryResponse.java index 2238ef2854..ae83e29ef8 100644 --- a/java-client/src/main/java/org/opensearch/client/transport/endpoints/DictionaryResponse.java +++ b/java-client/src/main/java/org/opensearch/client/transport/endpoints/DictionaryResponse.java @@ -36,6 +36,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import javax.annotation.Nullable; import org.opensearch.client.json.JsonpDeserializer; import org.opensearch.client.json.JsonpMapper; @@ -162,4 +163,19 @@ protected static { builder.putResult(name, tValueParser.deserialize(parser, params)); } ); } + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + Objects.hashCode(result); + return result; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DictionaryResponse other = (DictionaryResponse) o; + return Objects.equals(this.result, other.result); + } } diff --git a/java-codegen/build.gradle.kts b/java-codegen/build.gradle.kts index 535b03464e..57d6f3d545 100644 --- a/java-codegen/build.gradle.kts +++ b/java-codegen/build.gradle.kts @@ -171,6 +171,9 @@ dependencies { // MIT implementation("org.semver4j", "semver4j", "5.3.0") + // BSD-2-Clause + implementation("org.commonmark", "commonmark", "0.23.0") + // EPL-2.0 testImplementation(platform("org.junit:junit-bom:5.11.1")) testImplementation("org.junit.jupiter", "junit-jupiter") diff --git a/java-codegen/opensearch-openapi.yaml b/java-codegen/opensearch-openapi.yaml index e9e4e42740..45290b4ef6 100644 --- a/java-codegen/opensearch-openapi.yaml +++ b/java-codegen/opensearch-openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: OpenSearch API Specification - version: 1.0.0 + version: 0.2.0 x-api-version: 2.16.0 paths: /: @@ -337,6 +337,67 @@ paths: responses: '200': $ref: '#/components/responses/bulk@200' + /_bulk/stream: + post: + operationId: bulk_stream.0 + x-operation-group: bulk_stream + x-version-added: '2.17' + description: Allows to perform multiple index/update/delete operations using request response streaming. + externalDocs: + url: https://opensearch.org/docs/latest/api-reference/document-apis/bulk-streaming/ + parameters: + - $ref: '#/components/parameters/bulk_stream::query._source' + - $ref: '#/components/parameters/bulk_stream::query._source_excludes' + - $ref: '#/components/parameters/bulk_stream::query._source_includes' + - $ref: '#/components/parameters/bulk_stream::query.batch_interval' + - $ref: '#/components/parameters/bulk_stream::query.batch_size' + - $ref: '#/components/parameters/bulk_stream::query.pipeline' + - $ref: '#/components/parameters/bulk_stream::query.refresh' + - $ref: '#/components/parameters/bulk_stream::query.require_alias' + - $ref: '#/components/parameters/bulk_stream::query.routing' + - $ref: '#/components/parameters/bulk_stream::query.timeout' + - $ref: '#/components/parameters/bulk_stream::query.type' + - $ref: '#/components/parameters/bulk_stream::query.wait_for_active_shards' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + requestBody: + $ref: '#/components/requestBodies/bulk_stream' + responses: + '200': + $ref: '#/components/responses/bulk_stream@200' + put: + operationId: bulk_stream.1 + x-operation-group: bulk_stream + x-version-added: '2.17' + description: Allows to perform multiple index/update/delete operations using request response streaming. + externalDocs: + url: https://opensearch.org/docs/latest/api-reference/document-apis/bulk-streaming/ + parameters: + - $ref: '#/components/parameters/bulk_stream::query._source' + - $ref: '#/components/parameters/bulk_stream::query._source_excludes' + - $ref: '#/components/parameters/bulk_stream::query._source_includes' + - $ref: '#/components/parameters/bulk_stream::query.batch_interval' + - $ref: '#/components/parameters/bulk_stream::query.batch_size' + - $ref: '#/components/parameters/bulk_stream::query.pipeline' + - $ref: '#/components/parameters/bulk_stream::query.refresh' + - $ref: '#/components/parameters/bulk_stream::query.require_alias' + - $ref: '#/components/parameters/bulk_stream::query.routing' + - $ref: '#/components/parameters/bulk_stream::query.timeout' + - $ref: '#/components/parameters/bulk_stream::query.type' + - $ref: '#/components/parameters/bulk_stream::query.wait_for_active_shards' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + requestBody: + $ref: '#/components/requestBodies/bulk_stream' + responses: + '200': + $ref: '#/components/responses/bulk_stream@200' /_cache/clear: post: operationId: indices.clear_cache.0 @@ -2707,6 +2768,22 @@ paths: responses: '200': $ref: '#/components/responses/ingest.processor_grok@200' + /_insights/top_queries: + get: + operationId: insights.top_queries.0 + x-operation-group: insights.top_queries + x-version-added: '1.0' + description: Retrieves the top queries based on the given metric type (latency, CPU, or memory). + parameters: + - $ref: '#/components/parameters/insights.top_queries::query.type' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + responses: + '200': + $ref: '#/components/responses/insights.top_queries@200' /_mapping: get: operationId: indices.get_mapping.0 @@ -4620,6 +4697,8 @@ paths: parameters: - $ref: '#/components/parameters/notifications.get_configs::query.chime.url' - $ref: '#/components/parameters/notifications.get_configs::query.chime.url.keyword' + - $ref: '#/components/parameters/notifications.get_configs::query.config_id' + - $ref: '#/components/parameters/notifications.get_configs::query.config_id_list' - $ref: '#/components/parameters/notifications.get_configs::query.config_type' - $ref: '#/components/parameters/notifications.get_configs::query.created_time_ms' - $ref: '#/components/parameters/notifications.get_configs::query.description' @@ -9108,6 +9187,85 @@ paths: responses: '200': $ref: '#/components/responses/indices.validate_query@200' + /_wlm/query_group: + get: + operationId: wlm.get_query_group.0 + x-operation-group: wlm.get_query_group + x-version-added: '2.17' + description: Gets the specified QueryGroup or get all if no name is provided. + responses: + '200': + $ref: '#/components/responses/wlm.get_query_group@200' + parameters: + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + put: + operationId: wlm.create_query_group.0 + x-operation-group: wlm.create_query_group + x-version-added: '2.17' + description: Creates the specified query group. + requestBody: + $ref: '#/components/requestBodies/wlm.create_query_group' + responses: + '200': + $ref: '#/components/responses/wlm.create_query_group@200' + parameters: + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + /_wlm/query_group/{name}: + delete: + operationId: wlm.delete_query_group.0 + x-operation-group: wlm.delete_query_group + x-version-added: '2.17' + description: Deletes the specified QueryGroup. + parameters: + - $ref: '#/components/parameters/wlm.delete_query_group::path.name' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + responses: + '200': + $ref: '#/components/responses/wlm.delete_query_group@200' + get: + operationId: wlm.get_query_group.1 + x-operation-group: wlm.get_query_group + x-version-added: '2.17' + description: Gets the specified QueryGroup or get all if no name is provided. + parameters: + - $ref: '#/components/parameters/wlm.get_query_group::path.name' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + responses: + '200': + $ref: '#/components/responses/wlm.get_query_group@200' + put: + operationId: wlm.update_query_group.0 + x-operation-group: wlm.update_query_group + x-version-added: '2.17' + description: Updates the specified query group. + parameters: + - $ref: '#/components/parameters/wlm.update_query_group::path.name' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + requestBody: + $ref: '#/components/requestBodies/wlm.update_query_group' + responses: + '200': + $ref: '#/components/responses/wlm.update_query_group@200' /{alias}/_rollover: post: operationId: indices.rollover.0 @@ -9187,6 +9345,8 @@ paths: responses: '200': $ref: '#/components/responses/indices.delete@200' + '404': + $ref: '#/components/responses/indices.delete@404' get: operationId: indices.get.0 x-operation-group: indices.get @@ -9639,6 +9799,69 @@ paths: responses: '200': $ref: '#/components/responses/bulk@200' + /{index}/_bulk/stream: + post: + operationId: bulk_stream.2 + x-operation-group: bulk_stream + x-version-added: '2.17' + description: Allows to perform multiple index/update/delete operations using request response streaming. + externalDocs: + url: https://opensearch.org/docs/latest/api-reference/document-apis/bulk-streaming/ + parameters: + - $ref: '#/components/parameters/bulk_stream::path.index' + - $ref: '#/components/parameters/bulk_stream::query._source' + - $ref: '#/components/parameters/bulk_stream::query._source_excludes' + - $ref: '#/components/parameters/bulk_stream::query._source_includes' + - $ref: '#/components/parameters/bulk_stream::query.batch_interval' + - $ref: '#/components/parameters/bulk_stream::query.batch_size' + - $ref: '#/components/parameters/bulk_stream::query.pipeline' + - $ref: '#/components/parameters/bulk_stream::query.refresh' + - $ref: '#/components/parameters/bulk_stream::query.require_alias' + - $ref: '#/components/parameters/bulk_stream::query.routing' + - $ref: '#/components/parameters/bulk_stream::query.timeout' + - $ref: '#/components/parameters/bulk_stream::query.type' + - $ref: '#/components/parameters/bulk_stream::query.wait_for_active_shards' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + requestBody: + $ref: '#/components/requestBodies/bulk_stream' + responses: + '200': + $ref: '#/components/responses/bulk_stream@200' + put: + operationId: bulk_stream.3 + x-operation-group: bulk_stream + x-version-added: '2.17' + description: Allows to perform multiple index/update/delete operations using request response streaming. + externalDocs: + url: https://opensearch.org/docs/latest/api-reference/document-apis/bulk-streaming/ + parameters: + - $ref: '#/components/parameters/bulk_stream::path.index' + - $ref: '#/components/parameters/bulk_stream::query._source' + - $ref: '#/components/parameters/bulk_stream::query._source_excludes' + - $ref: '#/components/parameters/bulk_stream::query._source_includes' + - $ref: '#/components/parameters/bulk_stream::query.batch_interval' + - $ref: '#/components/parameters/bulk_stream::query.batch_size' + - $ref: '#/components/parameters/bulk_stream::query.pipeline' + - $ref: '#/components/parameters/bulk_stream::query.refresh' + - $ref: '#/components/parameters/bulk_stream::query.require_alias' + - $ref: '#/components/parameters/bulk_stream::query.routing' + - $ref: '#/components/parameters/bulk_stream::query.timeout' + - $ref: '#/components/parameters/bulk_stream::query.type' + - $ref: '#/components/parameters/bulk_stream::query.wait_for_active_shards' + - $ref: '#/components/parameters/_global::query.pretty' + - $ref: '#/components/parameters/_global::query.human' + - $ref: '#/components/parameters/_global::query.error_trace' + - $ref: '#/components/parameters/_global::query.source' + - $ref: '#/components/parameters/_global::query.filter_path' + requestBody: + $ref: '#/components/requestBodies/bulk_stream' + responses: + '200': + $ref: '#/components/responses/bulk_stream@200' /{index}/_cache/clear: post: operationId: indices.clear_cache.1 @@ -9985,6 +10208,8 @@ paths: responses: '200': $ref: '#/components/responses/delete@200' + '404': + $ref: '#/components/responses/delete@404' get: operationId: get.0 x-operation-group: get @@ -10013,6 +10238,8 @@ paths: responses: '200': $ref: '#/components/responses/get@200' + '404': + $ref: '#/components/responses/get@404' head: operationId: exists.0 x-operation-group: exists @@ -14213,6 +14440,108 @@ components: description: The amount of time that you plan to wait for the results. schema: type: string + bulk_stream::path.index: + in: path + name: index + description: Name of the data stream, index, or index alias to perform bulk actions on. + required: true + schema: + $ref: '#/components/schemas/_common:IndexName' + style: simple + bulk_stream::query._source: + in: query + name: _source + description: '`true` or `false` to return the `_source` field or not, or a list of fields to return.' + schema: + $ref: '#/components/schemas/_core.search:SourceConfigParam' + style: form + bulk_stream::query._source_excludes: + in: query + name: _source_excludes + description: A comma-separated list of source fields to exclude from the response. + schema: + $ref: '#/components/schemas/_common:Fields' + style: form + bulk_stream::query._source_includes: + in: query + name: _source_includes + description: A comma-separated list of source fields to include in the response. + schema: + $ref: '#/components/schemas/_common:Fields' + style: form + bulk_stream::query.batch_interval: + in: query + name: batch_interval + description: Specifies for how long bulk operations should be accumulated into a batch before sending the batch to data nodes. + schema: + $ref: '#/components/schemas/_common:Duration' + style: form + bulk_stream::query.batch_size: + in: query + name: batch_size + description: Specifies how many bulk operations should be accumulated into a batch before sending the batch to data nodes. + schema: + $ref: '#/components/schemas/_common:BatchSize' + style: form + x-default: 1 + bulk_stream::query.pipeline: + in: query + name: pipeline + description: |- + ID of the pipeline to use to preprocess incoming documents. + If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request. + If a final pipeline is configured it will always run, regardless of the value of this parameter. + schema: + type: string + style: form + bulk_stream::query.refresh: + in: query + name: refresh + description: |- + If `true`, OpenSearch refreshes the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` do nothing with refreshes. + Valid values: `true`, `false`, `wait_for`. + schema: + $ref: '#/components/schemas/_common:Refresh' + style: form + bulk_stream::query.require_alias: + in: query + name: require_alias + description: If `true`, the request's actions must target an index alias. + schema: + type: boolean + default: false + style: form + bulk_stream::query.routing: + in: query + name: routing + description: Custom value used to route operations to a specific shard. + schema: + $ref: '#/components/schemas/_common:RoutingInQueryString' + style: form + bulk_stream::query.timeout: + in: query + name: timeout + description: 'Period each action waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards.' + schema: + $ref: '#/components/schemas/_common:Duration' + style: form + bulk_stream::query.type: + name: type + in: query + description: Default document type for items which don't provide one. + schema: + type: string + description: Default document type for items which don't provide one. + bulk_stream::query.wait_for_active_shards: + in: query + name: wait_for_active_shards + description: |- + The number of shard copies that must be active before proceeding with the operation. + Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). + schema: + $ref: '#/components/schemas/_common:WaitForActiveShards' + style: form + x-default: '1' bulk::path.index: in: path name: index @@ -14274,7 +14603,7 @@ components: name: routing description: Custom value used to route operations to a specific shard. schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' style: form bulk::query.timeout: in: query @@ -16873,6 +17202,7 @@ components: description: Sets the minimum `_score` value that documents must have to be included in the result. schema: type: number + format: float style: form count::query.preference: in: query @@ -16896,7 +17226,7 @@ components: name: routing description: Custom value used to route operations to a specific shard. schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' style: form count::query.terminate_after: in: query @@ -16906,7 +17236,8 @@ components: If a query reaches this limit, OpenSearch terminates the query early. OpenSearch collects documents before sorting. schema: - type: number + type: integer + format: int32 style: form create_pit::path.index: name: index @@ -16951,7 +17282,7 @@ components: description: Comma-separated list of specific routing values. style: form schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' explode: true create::path.id: in: path @@ -16996,7 +17327,7 @@ components: name: routing description: Custom value used to route operations to a specific shard. schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' style: form create::query.timeout: in: query @@ -17125,6 +17456,7 @@ components: description: The throttle for this request in sub-requests per second. schema: type: number + format: float style: form delete_by_query::path.index: in: path @@ -17231,7 +17563,8 @@ components: name: from description: Starting offset. schema: - type: number + type: integer + format: int32 default: 0 style: form delete_by_query::query.ignore_unavailable: @@ -17255,7 +17588,8 @@ components: Maximum number of documents to process. Defaults to all documents. schema: - type: number + type: integer + format: int32 style: form delete_by_query::query.preference: in: query @@ -17296,6 +17630,7 @@ components: description: The throttle for this request in sub-requests per second. schema: type: number + format: float default: 0 style: form delete_by_query::query.routing: @@ -17303,7 +17638,7 @@ components: name: routing description: Custom value used to route operations to a specific shard. schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' style: form delete_by_query::query.scroll: in: query @@ -17317,7 +17652,8 @@ components: name: scroll_size description: Size of the scroll request that powers the operation. schema: - type: number + type: integer + format: int32 default: 100 style: form delete_by_query::query.search_timeout: @@ -17384,7 +17720,8 @@ components: When possible, let OpenSearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers. schema: - type: number + type: integer + format: int32 style: form delete_by_query::query.timeout: in: query @@ -17476,7 +17813,8 @@ components: name: if_primary_term description: Only perform the operation if the document has this primary term. schema: - type: number + type: integer + format: int64 style: form delete::query.if_seq_no: in: query @@ -17499,7 +17837,7 @@ components: name: routing description: Custom value used to route operations to a specific shard. schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' style: form delete::query.timeout: in: query @@ -17602,7 +17940,7 @@ components: name: routing description: Target the specified primary shard. schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' style: form exists_source::query.version: in: query @@ -17688,7 +18026,7 @@ components: name: routing description: Target the specified primary shard. schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' style: form exists::query.stored_fields: in: query @@ -17816,7 +18154,7 @@ components: name: routing description: Custom value used to route operations to a specific shard. schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' style: form explain::query.stored_fields: in: query @@ -18080,7 +18418,7 @@ components: name: routing description: Target the specified primary shard. schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' style: form get_source::query.version: in: query @@ -18160,7 +18498,7 @@ components: name: routing description: Target the specified primary shard. schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' style: form get::query.stored_fields: in: query @@ -18207,7 +18545,8 @@ components: name: if_primary_term description: Only perform the operation if the document has this primary term. schema: - type: number + type: integer + format: int64 style: form index::query.if_seq_no: in: query @@ -18261,7 +18600,7 @@ components: name: routing description: Custom value used to route operations to a specific shard. schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' style: form index::query.timeout: in: query @@ -20953,6 +21292,17 @@ components: type: boolean default: false style: form + insights.top_queries::query.type: + name: type + in: query + required: true + description: Get top n queries by a specific metric. + schema: + type: string + enum: + - cpu + - latency + - memory ism.add_policy::path.index: name: index in: path @@ -21324,7 +21674,7 @@ components: description: Comma-separated list of specific routing values. style: form schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' explode: true knn.search_models::query.scroll: name: scroll @@ -21598,7 +21948,7 @@ components: name: routing description: Custom value used to route operations to a specific shard. schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' style: form mget::query.stored_fields: in: query @@ -21685,7 +22035,8 @@ components: name: max_concurrent_searches description: Maximum number of concurrent searches the API can run. schema: - type: number + type: integer + format: int32 style: form msearch_template::query.rest_total_hits_as_int: in: query @@ -21734,14 +22085,16 @@ components: name: max_concurrent_searches description: Maximum number of concurrent searches the multi search API can execute. schema: - type: number + type: integer + format: int32 style: form msearch::query.max_concurrent_shard_requests: in: query name: max_concurrent_shard_requests description: Maximum number of concurrent shard requests that each sub-search request executes per node. schema: - type: number + type: integer + format: int32 default: 5 style: form msearch::query.pre_filter_shard_size: @@ -21749,7 +22102,8 @@ components: name: pre_filter_shard_size description: Defines a threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method i.e., if date filters are mandatory to match but the shard bounds and the query are disjoint. schema: - type: number + type: integer + format: int32 style: form msearch::query.rest_total_hits_as_int: in: query @@ -21854,7 +22208,7 @@ components: name: routing description: Custom value used to route operations to a specific shard. schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' style: form mtermvectors::query.term_statistics: in: query @@ -22152,6 +22506,20 @@ components: in: query schema: type: string + notifications.get_configs::query.config_id: + name: config_id + in: query + description: Notification configuration ID. + schema: + type: string + notifications.get_configs::query.config_id_list: + name: config_id_list + in: query + description: Notification configuration IDs. + schema: + type: array + items: + type: string notifications.get_configs::query.config_type: name: config_type in: query @@ -22561,6 +22929,7 @@ components: description: The throttle for this request in sub-requests per second. schema: type: number + format: float style: form reindex::query.max_docs: name: max_docs @@ -22585,6 +22954,7 @@ components: Defaults to no throttle. schema: type: number + format: float default: 0 style: form reindex::query.scroll: @@ -22861,7 +23231,7 @@ components: name: routing description: Custom value used to route operations to a specific shard. schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' style: form search_template::path.index: in: path @@ -22953,7 +23323,7 @@ components: name: routing description: Custom value used to route operations to a specific shard. schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' style: form search_template::query.scroll: in: query @@ -23067,7 +23437,8 @@ components: The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. schema: - type: number + type: integer + format: int32 default: 512 style: form search::query.cancel_after_time_interval: @@ -23138,7 +23509,8 @@ components: By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters. To page through more hits, use the `search_after` parameter. schema: - type: number + type: integer + format: int32 default: 0 style: form search::query.ignore_throttled: @@ -23179,7 +23551,8 @@ components: Defines the number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests. schema: - type: number + type: integer + format: int32 default: 5 style: form search::query.phase_took: @@ -23201,7 +23574,8 @@ components: the request targets one or more read-only index; the primary sort of the query targets an indexed field. schema: - type: number + type: integer + format: int32 style: form search::query.preference: in: query @@ -23250,7 +23624,7 @@ components: name: routing description: Custom value used to route operations to a specific shard. schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' style: form search::query.scroll: in: query @@ -23291,7 +23665,8 @@ components: By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters. To page through more hits, use the `search_after` parameter. schema: - type: number + type: integer + format: int32 default: 10 style: form search::query.sort: @@ -23348,7 +23723,8 @@ components: Number of suggestions to return. This parameter can only be used when the `suggest_field` and `suggest_text` query string parameters are specified. schema: - type: number + type: integer + format: int32 style: form search::query.suggest_text: in: query @@ -23372,7 +23748,8 @@ components: Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers. If set to `0` (default), the query does not terminate early. schema: - type: number + type: integer + format: int32 style: form search::query.timeout: in: query @@ -24395,7 +24772,7 @@ components: name: routing description: Custom value used to route operations to a specific shard. schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' style: form termvectors::query.term_statistics: in: query @@ -24537,6 +24914,7 @@ components: description: The throttle for this request in sub-requests per second. schema: type: number + format: float style: form update_by_query::path.index: in: path @@ -24644,7 +25022,8 @@ components: name: from description: Starting offset. schema: - type: number + type: integer + format: int32 default: 0 style: form update_by_query::query.ignore_unavailable: @@ -24668,7 +25047,8 @@ components: Maximum number of documents to process. Defaults to all documents. schema: - type: number + type: integer + format: int32 style: form update_by_query::query.pipeline: in: query @@ -24717,6 +25097,7 @@ components: description: The throttle for this request in sub-requests per second. schema: type: number + format: float default: 0 style: form update_by_query::query.routing: @@ -24724,7 +25105,7 @@ components: name: routing description: Custom value used to route operations to a specific shard. schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' style: form update_by_query::query.scroll: in: query @@ -24738,7 +25119,8 @@ components: name: scroll_size description: Size of the scroll request that powers the operation. schema: - type: number + type: integer + format: int32 default: 100 style: form update_by_query::query.search_timeout: @@ -24801,7 +25183,8 @@ components: When possible, let OpenSearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers. schema: - type: number + type: integer + format: int32 style: form update_by_query::query.timeout: in: query @@ -24880,7 +25263,8 @@ components: name: if_primary_term description: Only perform the operation if the document has this primary term. schema: - type: number + type: integer + format: int64 style: form update::query.if_seq_no: in: query @@ -24920,7 +25304,8 @@ components: name: retry_on_conflict description: Specify how many times should the operation be retried when a conflict occurs. schema: - type: number + type: integer + format: int32 default: 0 style: form update::query.routing: @@ -24928,7 +25313,7 @@ components: name: routing description: Custom value used to route operations to a specific shard. schema: - $ref: '#/components/schemas/_common:Routing' + $ref: '#/components/schemas/_common:RoutingInQueryString' style: form update::query.timeout: in: query @@ -24951,6 +25336,27 @@ components: $ref: '#/components/schemas/_common:WaitForActiveShards' style: form x-default: '1' + wlm.delete_query_group::path.name: + name: name + in: path + description: QueryGroup name. + schema: + type: string + required: true + wlm.get_query_group::path.name: + name: name + in: path + description: QueryGroup name. + schema: + type: string + required: true + wlm.update_query_group::path.name: + name: name + in: path + description: QueryGroup name. + schema: + type: string + required: true requestBodies: asynchronous_search.search: content: @@ -24969,6 +25375,18 @@ components: - type: object description: The operation definition and data (action-data pairs), separated by newlines required: true + bulk_stream: + content: + application/x-ndjson: + schema: + type: array + items: + anyOf: + - $ref: '#/components/schemas/_core.bulk:OperationContainer' + - $ref: '#/components/schemas/_core.bulk:UpdateAction' + - type: object + description: The operation definition and data (action-data pairs), separated by newlines + required: true cat.pit_segments: content: application/json: @@ -25091,7 +25509,8 @@ components: properties: max_docs: description: The maximum number of documents to delete. - type: number + type: integer + format: int32 query: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' slice: @@ -25130,8 +25549,6 @@ components: $ref: '#/components/schemas/_common:Fields' index_filter: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' - runtime_mappings: - $ref: '#/components/schemas/_common.mapping:RuntimeFields' description: An index filter specified with the Query DSL flow_framework.create: content: @@ -25360,8 +25777,6 @@ components: $ref: '#/components/schemas/_common.mapping:RoutingField' _source: $ref: '#/components/schemas/_common.mapping:SourceField' - runtime: - $ref: '#/components/schemas/_common.mapping:RuntimeFields' description: The mapping definition required: true indices.put_settings: @@ -25628,11 +26043,16 @@ components: format: int32 description: type: string + mode: + type: string + compression_level: + type: string method: type: string + spaceType: + type: string required: - dimension - - method - training_field - training_index required: true @@ -25878,11 +26298,13 @@ components: $ref: '#/components/schemas/_core.reindex:Destination' max_docs: description: The maximum number of documents to reindex. - type: number + type: integer + format: int32 script: $ref: '#/components/schemas/_common:Script' size: - type: number + type: integer + format: int32 source: $ref: '#/components/schemas/_core.reindex:Source' required: @@ -25993,7 +26415,8 @@ components: Needs to be non-negative. By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters. To page through more hits, use the `search_after` parameter. - type: number + type: integer + format: int32 highlight: $ref: '#/components/schemas/_core.search:Highlight' track_total_hits: @@ -26005,6 +26428,7 @@ components: type: object additionalProperties: type: number + format: float docvalue_fields: description: |- Array of wildcard (`*`) patterns. @@ -26019,6 +26443,7 @@ components: Minimum `_score` for matching documents. Documents with a lower `_score` are not included in the search results. type: number + format: float post_filter: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' profile: @@ -26047,7 +26472,8 @@ components: The number of hits to return. By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters. To page through more hits, use the `search_after` parameter. - type: number + type: integer + format: int32 slice: $ref: '#/components/schemas/_common:SlicedScroll' sort: @@ -26073,7 +26499,8 @@ components: When possible, let OpenSearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers. If set to `0` (default), the query does not terminate early. - type: number + type: integer + format: int32 timeout: description: |- Specifies the period of time to wait for a response from each shard. @@ -26093,8 +26520,6 @@ components: $ref: '#/components/schemas/_common:Fields' pit: $ref: '#/components/schemas/_core.search:PointInTimeReference' - runtime_mappings: - $ref: '#/components/schemas/_common.mapping:RuntimeFields' stats: description: |- Stats groups to associate with the search. @@ -26527,7 +26952,8 @@ components: properties: max_docs: description: The maximum number of documents to update. - type: number + type: integer + format: int32 query: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' script: @@ -26537,6 +26963,18 @@ components: conflicts: $ref: '#/components/schemas/_common:Conflicts' description: The search definition using the Query DSL + wlm.create_query_group: + content: + application/json: + schema: + $ref: '#/components/schemas/wlm._common:QueryGroupCreate' + required: true + wlm.update_query_group: + content: + application/json: + schema: + $ref: '#/components/schemas/wlm._common:QueryGroupUpdate' + required: true responses: asynchronous_search.delete@200: content: @@ -26561,6 +26999,32 @@ components: application/json: schema: $ref: '#/components/schemas/asynchronous_search._common:StatsResponse' + bulk_stream@200: + content: + application/json: + schema: + type: object + properties: + errors: + type: boolean + items: + type: array + items: + type: object + additionalProperties: + $ref: '#/components/schemas/_core.bulk:ResponseItem' + minProperties: 1 + maxProperties: 1 + took: + type: integer + format: int64 + ingest_took: + type: integer + format: int64 + required: + - errors + - items + - took bulk@200: content: application/json: @@ -26578,9 +27042,11 @@ components: minProperties: 1 maxProperties: 1 took: - type: number + type: integer + format: int64 ingest_took: - type: number + type: integer + format: int64 required: - errors - items @@ -26836,7 +27302,8 @@ components: succeeded: type: boolean num_freed: - type: number + type: integer + format: int32 required: - num_freed - succeeded @@ -27067,7 +27534,8 @@ components: terminated_early: type: boolean count: - type: number + type: integer + format: int64 _shards: $ref: '#/components/schemas/_common:ShardStatistics' required: @@ -27162,6 +27630,11 @@ components: application/json: schema: $ref: '#/components/schemas/_common:WriteResponseBase' + delete@404: + content: + application/json: + schema: + $ref: '#/components/schemas/_common:WriteResponseBase' exists_source@200: content: application/json: {} @@ -27445,6 +27918,11 @@ components: application/json: schema: $ref: '#/components/schemas/_core.get:GetResult' + get@404: + content: + application/json: + schema: + $ref: '#/components/schemas/_core.get:GetResult' index@200: content: application/json: @@ -27600,6 +28078,11 @@ components: application/json: schema: $ref: '#/components/schemas/_common:IndicesResponseBase' + indices.delete@404: + content: + application/json: + schema: + $ref: '#/components/schemas/indices._common:IndexErrorCause' indices.exists_alias@200: content: application/json: {} @@ -27997,6 +28480,11 @@ components: $ref: '#/components/schemas/ingest.simulate:PipelineSimulation' required: - docs + insights.top_queries@200: + content: + application/json: + schema: + $ref: '#/components/schemas/insights._common:TopQueriesResponse' ism.add_policy@200: content: application/json: @@ -28066,10 +28554,23 @@ components: schema: $ref: '#/components/schemas/ism._common:RetryIndexResponse' knn.delete_model@200: {} - knn.get_model@200: {} + knn.get_model@200: + content: + application/json: + schema: + type: object knn.search_models@200: {} knn.stats@200: {} - knn.train_model@200: {} + knn.train_model@200: + content: + application/json: + schema: + type: object + properties: + model_id: + type: string + required: + - model_id knn.warmup@200: {} mget@200: content: @@ -28474,6 +28975,7 @@ components: metric_score: description: The overall evaluation quality calculated by the defined metric type: number + format: double details: description: The details section contains one entry for every query in the original requests section, keyed by the search request id type: object @@ -28627,7 +29129,8 @@ components: type: object properties: took: - type: number + type: integer + format: int64 timed_out: type: boolean _shards: @@ -28646,8 +29149,10 @@ components: type: object max_score: type: number + format: float num_reduce_phases: - type: number + type: integer + format: int32 profile: $ref: '#/components/schemas/_core.search:Profile' pit_id: @@ -29345,7 +29850,7 @@ components: type: object properties: accepted: - description: Equals `true` if the snapshot was accepted. Present when the request had `wait_for_completion` set to `false` + description: Returns `true` if the snapshot was accepted. Present when the request had `wait_for_completion` set to `false`. type: boolean snapshot: $ref: '#/components/schemas/snapshot._common:SnapshotInfo' @@ -29372,33 +29877,23 @@ components: schema: type: object properties: - responses: - type: array - items: - $ref: '#/components/schemas/snapshot.get:SnapshotResponseItem' snapshots: type: array items: $ref: '#/components/schemas/snapshot._common:SnapshotInfo' - total: - description: The total number of snapshots that match the request when ignoring size limit or after query parameter. - type: number - remaining: - description: The number of remaining snapshots that were not returned due to size limits and that can be fetched by additional requests using the next field value. - type: number required: - - remaining - - total + - snapshots snapshot.restore@200: content: application/json: schema: type: object properties: + accepted: + description: Returns `true` if the restore was accepted. Present when the request had `wait_for_completion` set to `false`. + type: boolean snapshot: $ref: '#/components/schemas/snapshot.restore:SnapshotRestore' - required: - - snapshot snapshot.status@200: content: application/json: @@ -29501,7 +29996,8 @@ components: additionalProperties: $ref: '#/components/schemas/_core.termvectors:TermVector' took: - type: number + type: integer + format: int64 _version: $ref: '#/components/schemas/_common:VersionNumber' required: @@ -29573,6 +30069,38 @@ components: application/json: schema: $ref: '#/components/schemas/_core.update:UpdateWriteResponseBase' + wlm.create_query_group@200: + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/wlm._common:QueryGroupResponse' + wlm.delete_query_group@200: + description: '' + content: + application/json: + schema: + type: object + properties: + acknowledged: + type: boolean + wlm.get_query_group@200: + description: '' + content: + application/json: + schema: + type: object + properties: + query_groups: + type: array + items: + $ref: '#/components/schemas/wlm._common:QueryGroupResponse' + wlm.update_query_group@200: + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/wlm._common:QueryGroupResponse' schemas: _common:AcknowledgedResponseBase: type: object @@ -29608,6 +30136,16 @@ components: $ref: '#/components/schemas/_common:TransportAddress' required: - name + _common:BatchSize: + type: integer + format: int64 + _common:BuiltinScriptLanguage: + type: string + enum: + - expression + - java + - mustache + - painless _common:BulkByScrollFailure: anyOf: - $ref: '#/components/schemas/_common:BulkItemResponseFailure' @@ -29641,7 +30179,7 @@ components: type: integer format: int64 updated: - description: The number of documents that were successfully updated, for example, a document with same ID already existed prior to reindex updating it. + description: The number of documents that were successfully updated after the reindex operation. type: integer format: int64 created: @@ -29653,11 +30191,11 @@ components: type: integer format: int64 batches: - description: The number of scroll responses pulled back by the reindex. + description: The number of scroll responses pulled back by the reindex operation. type: integer format: int32 version_conflicts: - description: The number of version conflicts that reindex hits. + description: The number of version conflicts encountered by the reindex operation. type: integer format: int64 noops: @@ -29671,7 +30209,7 @@ components: throttled: $ref: '#/components/schemas/_common:Duration' requests_per_second: - description: The number of requests per second effectively executed during the reindex. + description: The number of requests per second effectively executed during the reindex operation. type: number format: float canceled: @@ -29768,17 +30306,23 @@ components: type: object properties: skipped: - type: number + type: integer + format: int32 successful: - type: number + type: integer + format: int32 total: - type: number + type: integer + format: int32 running: - type: number + type: integer + format: int32 partial: - type: number + type: integer + format: int32 failed: - type: number + type: integer + format: int32 details: type: object additionalProperties: @@ -29794,7 +30338,7 @@ components: type: object properties: size_in_bytes: - description: Total amount, in bytes, of memory used for completion across all shards assigned to selected nodes. + description: The total amount, in bytes, of memory used for completion across all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:ByteCount' size: $ref: '#/components/schemas/_common:HumanReadableByteCount' @@ -29814,12 +30358,16 @@ components: properties: top: type: number + format: double bottom: type: number + format: double left: type: number + format: double right: type: number + format: double required: - bottom - left @@ -29839,8 +30387,8 @@ components: type: string _common:DateTime: description: |- - A date and time, either as a string whose format can depend on the context (defaulting to ISO 8601), or a - number of milliseconds since the Epoch. OpenSearch accepts both as input, but will generally output a string + A date and time, either as a string whose format depends on the context (defaulting to ISO_8601) or the + number of milliseconds since the epoch. OpenSearch accepts both as an input but will generally output a string. representation. oneOf: - type: string @@ -29856,7 +30404,7 @@ components: enum: - b - l - - no + - 'no' _common:DFRBasicModel: type: string enum: @@ -29886,31 +30434,36 @@ components: properties: count: description: |- - Total number of non-deleted documents across all primary shards assigned to selected nodes. + The total number of non-deleted documents across all primary shards assigned to the selected nodes. This number is based on documents in Lucene segments and may include documents from nested fields. type: number deleted: description: |- - Total number of deleted documents across all primary shards assigned to selected nodes. - This number is based on documents in Lucene segments. - OpenSearch reclaims the disk space of deleted Lucene documents when a segment is merged. + The total number of deleted documents across all primary shards assigned to the selected nodes. + This number is based on the number of documents stored in Lucene segments. + OpenSearch reclaims the disk space previously occupied by the deleted Lucene documents when a segment is merged. type: number required: - count _common:DocStatus: - description: Item level REST category class codes during indexing. + description: The item level REST category class codes during indexing. type: object properties: 1xx: - type: number + type: integer + format: int32 2xx: - type: number + type: integer + format: int32 3xx: - type: number + type: integer + format: int32 4xx: - type: number + type: integer + format: int32 5xx: - type: number + type: integer + format: int32 _common:Duration: description: |- A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and @@ -29918,7 +30471,7 @@ components: pattern: ^([0-9\.]+)(?:d|h|m|s|ms|micros|nanos)$ type: string _common:DurationLarge: - description: 'A date histogram interval. Similar to `Duration` with additional units: `w` (week), `M` (month), `q` (quarter) and `y` (year).' + description: 'A date histogram interval, similar to `Duration`, with support for additional units: `w` (week), `M` (month), `q` (quarter), and `y` (year).' type: string _common:DurationValueUnitMillis: allOf: @@ -29938,13 +30491,13 @@ components: type: object properties: type: - description: The type of error + description: The type of error. type: string reason: - description: A human-readable explanation of the error, in english + description: A human-readable explanation of the error, in English. type: string stack_trace: - description: The server stack trace. Present only if the `error_trace=true` parameter was sent with the request. + description: The server stack trace, present only if the `error_trace=true` parameter was sent with the request. type: string caused_by: $ref: '#/components/schemas/_common:ErrorCause' @@ -29960,7 +30513,7 @@ components: - type additionalProperties: title: metadata - description: Additional details about the error. + description: Any additional information about the error. _common:ErrorResponseBase: type: object properties: @@ -29972,13 +30525,22 @@ components: - error - status _common:ExpandWildcard: - type: string - enum: - - all - - closed - - hidden - - none - - open + oneOf: + - type: string + const: all + description: Match any index, including hidden ones. + - type: string + const: closed + description: Match closed, non-hidden indices. + - type: string + const: hidden + description: Match hidden indices. Must be combined with open, closed, or both. + - type: string + const: none + description: Wildcard expressions are not accepted. + - type: string + const: open + description: Match open, non-hidden indices. _common:ExpandWildcards: oneOf: - $ref: '#/components/schemas/_common:ExpandWildcard' @@ -29986,7 +30548,7 @@ components: items: $ref: '#/components/schemas/_common:ExpandWildcard' _common:Field: - description: Path to field or array of paths. Some API's support wildcards in the path to select multiple fields. + description: The path to a field or an array of paths. Some APIs support wildcards in the path, which allows you to select multiple fields. type: string _common:FielddataStats: type: object @@ -30057,19 +30619,24 @@ components: _common:Fuzziness: oneOf: - type: string - - type: number + - type: integer + format: int32 _common:GeoBounds: description: |- - A geo bounding box. It can be represented in various ways: - - as 4 top/bottom/left/right coordinates - - as 2 top_left / bottom_right points - - as 2 top_right / bottom_left points - - as a WKT bounding box. + A geo-bounding box. It can be represented in the following ways: + - As 4 top/bottom/left/right coordinates. + - As 2 top_left/bottom_right points. + - As 2 top_right/bottom_left points. + - As a Well Known Text (WKT) bounding box. oneOf: - - $ref: '#/components/schemas/_common:CoordsGeoBounds' - - $ref: '#/components/schemas/_common:TopLeftBottomRightGeoBounds' - - $ref: '#/components/schemas/_common:TopRightBottomLeftGeoBounds' - - $ref: '#/components/schemas/_common:WktGeoBounds' + - title: coords + $ref: '#/components/schemas/_common:CoordsGeoBounds' + - title: tlbr + $ref: '#/components/schemas/_common:TopLeftBottomRightGeoBounds' + - title: trbl + $ref: '#/components/schemas/_common:TopRightBottomLeftGeoBounds' + - title: wkt + $ref: '#/components/schemas/_common:WktGeoBounds' _common:GeoDistanceSort: type: object properties: @@ -30098,9 +30665,10 @@ components: required: - geohash _common:GeoHashPrecision: - description: A precision that can be expressed as a geohash length between 1 and 12, or a distance measure like "1km", "10m". + description: The level of geohash precision, which can be expressed as a geohash length between 1 and 12 or as a distance measure, such as "1km" or "10m". oneOf: - - type: number + - type: integer + format: int32 - type: string _common:GeoHexCell: description: A map hex cell (H3) reference. @@ -30112,29 +30680,35 @@ components: description: Always `"LineString"` type: string coordinates: - description: Array of `[lon, lat]` coordinates + description: An array of `[lon, lat]` coordinates. type: array items: type: array items: type: number + format: double required: - coordinates - type _common:GeoLocation: description: |- - A latitude/longitude as a 2 dimensional point. It can be represented in various ways: - - as a `{lat, long}` object - - as a geo hash value - - as a `[lon, lat]` array - - as a string in `", "` or WKT point formats. + A latitude/longitude as a two-dimensional point. It can be represented in the following ways: + - As a `{lat, long}` object. + - As a geohash value. + - As a `[lon, lat]` array. + - As a string in `", "` or WKT point format. oneOf: - - $ref: '#/components/schemas/_common:LatLonGeoLocation' - - $ref: '#/components/schemas/_common:GeoHashLocation' - - type: array + - title: latlon + $ref: '#/components/schemas/_common:LatLonGeoLocation' + - title: geohash + $ref: '#/components/schemas/_common:GeoHashLocation' + - title: coords + type: array items: type: number - - type: string + format: double + - title: text + type: string _common:GeoShapeRelation: type: string enum: @@ -30330,7 +30904,8 @@ components: _seq_no: $ref: '#/components/schemas/_common:SequenceNumber' _primary_term: - type: number + type: integer + format: int32 _routing: $ref: '#/components/schemas/_common:Routing' _source: @@ -30339,21 +30914,24 @@ components: required: - found _common:InlineScript: - allOf: - - $ref: '#/components/schemas/_common:ScriptBase' - - type: object - properties: - lang: - $ref: '#/components/schemas/_common:ScriptLanguage' - options: - type: object - additionalProperties: - type: string - source: - description: The script source. - type: string - required: - - source + oneOf: + - title: source + type: string + - allOf: + - $ref: '#/components/schemas/_common:ScriptBase' + - type: object + properties: + lang: + $ref: '#/components/schemas/_common:ScriptLanguage' + options: + type: object + additionalProperties: + type: string + source: + description: The script source. + type: string + required: + - source _common:Ip: type: string _common:KnnField: @@ -30362,26 +30940,42 @@ components: vector: $ref: '#/components/schemas/_common:QueryVector' k: - description: The final number of nearest neighbors to return as top hits. - type: number + description: The total number of nearest neighbors to return as top hits. + type: integer + format: int32 min_score: - description: The minimum similarity score for a neighbor to be considered a hit. + description: The minimum similarity score required in order for a neighbor to be considered a hit. type: number + format: float x-version-added: '2.14' max_distance: - description: The maximum physical distance in vector space for a neighbor to be considered a hit. + description: The maximum physical vector space distance required in order for a neighbor to be considered a hit. type: number + format: float x-version-added: '2.14' filter: - description: Filters for the kNN search query. + description: The filters for the k-NN search query. oneOf: - $ref: '#/components/schemas/_common.query_dsl:QueryContainer' - type: array items: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' boost: - description: Boost value to apply to kNN scores + description: The boost value applied to k-NN scores. type: number + format: float + method_parameters: + type: object + x-version-added: '2.16' + additionalProperties: + type: integer + format: int32 + rescore: + type: object + x-version-added: '2.17' + additionalProperties: + type: number + format: float required: - vector _common:LatLonGeoLocation: @@ -30390,9 +30984,11 @@ components: lat: description: Latitude type: number + format: double lon: description: Longitude type: number + format: double required: - lat - lon @@ -30454,9 +31050,10 @@ components: type: object additionalProperties: true _common:MinimumShouldMatch: - description: The minimum number of terms that should match as integer, percentage or range. + description: The minimum number of terms that should match as an integer, percentage, or range. oneOf: - - type: number + - type: integer + format: int32 - type: string _common:MultiTermQueryRewrite: type: string @@ -30481,7 +31078,8 @@ components: filter: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' max_children: - type: number + type: integer + format: int32 nested: $ref: '#/components/schemas/_common:NestedSortValue' path: @@ -30545,7 +31143,7 @@ components: - master deprecated: true x-version-deprecated: '2.0' - x-deprecation-message: To promote inclusive language, use 'cluster_manager' instead. + x-deprecation-message: Use 'cluster_manager' instead. - type: string enum: - cluster_manager @@ -30597,26 +31195,18 @@ components: items: $ref: '#/components/schemas/_common:ErrorCause' total: - description: Total number of nodes selected by the request. + description: The total number of nodes selected by the request. type: integer successful: - description: Number of nodes that responded successfully to the request. + description: The number of nodes that responded successfully to the request. type: integer failed: - description: Number of nodes that rejected the request or failed to respond. If this value is not 0, a reason for the rejection or failure is included in the response. + description: The number of nodes that rejected the request or failed to respond. If this value is not 0, then a reason for the rejection or failure is included in the response. type: integer required: - failed - successful - total - _common:Normalization: - type: string - enum: - - h1 - - h2 - - h3 - - no - - z _common:OpenSearchVersionInfo: type: object properties: @@ -30659,6 +31249,7 @@ components: type: string _common:PercentageNumber: type: number + format: double _common:PercentageString: type: string pattern: \d+(\.\d+)? @@ -30688,8 +31279,8 @@ components: type: string _common:PipeSeparatedFlagsSimpleQueryStringFlag: description: |- - A set of flags that can be represented as a single enum value or a set of values that are encoded - as a pipe-separated string + A set of flags represented as a single enum value or a set of values that are encoded + as a pipe-separated string. Depending on the target language, code generators can use this hint to generate language specific flags enum constructs and the corresponding (de-)serialization code. @@ -30737,28 +31328,28 @@ components: properties: cache_count: description: |- - Total number of entries added to the query cache across all shards assigned to selected nodes. - This number includes current and evicted entries. + The total number of entries added to the query cache across all shards assigned to the selected nodes. + This number includes all current and evicted entries. type: number cache_size: - description: Total number of entries currently in the query cache across all shards assigned to selected nodes. + description: The total number of entries currently stored in the query cache across all shards assigned to the selected nodes. type: number evictions: - description: Total number of query cache evictions across all shards assigned to selected nodes. + description: The total number of query cache evictions across all shards assigned to the selected nodes. type: number hit_count: - description: Total count of query cache hits across all shards assigned to selected nodes. + description: The total number of query cache hits across all shards assigned to the selected nodes. type: number memory_size: $ref: '#/components/schemas/_common:HumanReadableByteCount' memory_size_in_bytes: - description: Total amount, in bytes, of memory used for the query cache across all shards assigned to selected nodes. + description: The total amount, in bytes, of memory used for the query cache across all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:ByteCount' miss_count: - description: Total count of query cache misses across all shards assigned to selected nodes. + description: The total number of query cache misses across all shards assigned to the selected nodes. type: number total_count: - description: Total count of hits and misses in the query cache across all shards assigned to selected nodes. + description: The total number of hits and misses stored in the query cache across all shards assigned to the selected nodes. type: number required: - cache_count @@ -30772,6 +31363,7 @@ components: type: array items: type: number + format: float _common:RankBase: type: object _common:RankContainer: @@ -30839,10 +31431,10 @@ components: description: Statistics related to downloads to the remote segment store. properties: total_download_size: - description: The total amount of data download from the remote segment store. + description: The total amount of data downloaded from the remote segment store. $ref: '#/components/schemas/_common:RemoteStoreUploadDownloadStats' total_time_spent: - description: The total duration, spent on downloads from the remote segment store. + description: The total amount of time spent on downloads from the remote segment store. $ref: '#/components/schemas/_common:Duration' total_time_spent_in_millis: description: The total duration, in milliseconds, spent on downloads from the remote segment store. @@ -30852,7 +31444,7 @@ components: - total_time_spent_in_millis _common:RemoteStoreStats: type: object - description: Statistics about remote segment store operations. + description: Statistics related to remote segment store operations. properties: upload: $ref: '#/components/schemas/_common:RemoteStoreUploadStats' @@ -30927,10 +31519,10 @@ components: description: The amount of data, in bytes, uploaded or downloaded to/from the remote segment store. properties: failed: - description: The number of bytes that failed to upload/upload to/from the remote segment store. + description: The number of bytes that failed to upload to/from the remote segment store. $ref: '#/components/schemas/_common:HumanReadableByteCount' failed_bytes: - description: The number of bytes that failed to upload/upload to/from the remote segment store. + description: The number of bytes that failed to upload to/from the remote segment store. $ref: '#/components/schemas/_common:ByteCount' started: description: The number of bytes to upload/download to/from the remote segment store after the upload/download has started. @@ -30991,7 +31583,7 @@ components: refresh_size_lag: $ref: '#/components/schemas/_common:RemoteStoreUploadRefreshSizeLagStats' total_time_spent: - description: The total amount of time, spent on uploads to the remote segment store. + description: The total amount of time spent on uploads to the remote segment store. $ref: '#/components/schemas/_common:Duration' total_time_spent_in_millis: description: The total amount of time, in milliseconds, spent on uploads to the remote segment store. @@ -31033,6 +31625,10 @@ components: type: number total: type: number + _common:ResourceType: + type: string + enum: + - index_or_alias _common:Result: type: string enum: @@ -31054,6 +31650,8 @@ components: - bulk - search _common:Routing: + type: string + _common:RoutingInQueryString: oneOf: - type: string - type: array @@ -31065,10 +31663,10 @@ components: - type: object properties: rank_constant: - description: How much influence documents in individual result sets per query have over the final ranked result set + description: To what degree documents found in individual result sets per query influence the final ranked result set. type: number window_size: - description: Size of the individual result sets per query + description: The size of the individual result sets per query. type: number _common:ScheduleTimeOfDay: description: A time of day, expressed either as `hh:mm`, `noon`, `midnight`, or an hour/minutes structure. @@ -31082,15 +31680,17 @@ components: $ref: '#/components/schemas/_common:SortOrder' _common:Script: oneOf: - - $ref: '#/components/schemas/_common:InlineScript' - - $ref: '#/components/schemas/_common:StoredScriptId' + - title: inline + $ref: '#/components/schemas/_common:InlineScript' + - title: stored + $ref: '#/components/schemas/_common:StoredScriptId' _common:ScriptBase: type: object properties: params: description: |- - Specifies any named parameters that are passed into the script as variables. - Use parameters instead of hard-coded values to decrease compile time. + Specifies any named parameters that are passed into the script as variables. + Use parameters instead of hard-coded values to decrease compilation time. type: object additionalProperties: true _common:ScriptField: @@ -31103,12 +31703,11 @@ components: required: - script _common:ScriptLanguage: - type: string - enum: - - expression - - java - - mustache - - painless + anyOf: + - title: builtin + $ref: '#/components/schemas/_common:BuiltinScriptLanguage' + - title: custom + type: string _common:ScriptSort: type: object properties: @@ -31163,39 +31762,39 @@ components: description: The number of open search contexts. type: number query_current: - description: The number of shard query operations that are currently running. + description: The number of currently running shard query operations. type: number query_time: - description: The total amount of time for all shard query operations. + description: The total amount of time taken to complete all shard query operations. $ref: '#/components/schemas/_common:Duration' query_time_in_millis: - description: The total amount of time for all shard query operations, in milliseconds. + description: The total amount of time taken to complete all shard query operations, in milliseconds. $ref: '#/components/schemas/_common:DurationValueUnitMillis' query_total: description: The total number of shard query operations. type: number concurrent_query_total: - description: The total number of query operations that use concurrent segment search. + description: The total number of query operations using concurrent segment search. type: number concurrent_query_time: $ref: '#/components/schemas/_common:Duration' concurrent_query_time_in_millis: - description: The total amount of time taken by all query operations that use concurrent segment search, in milliseconds. + description: The total amount of time taken by all query operations using concurrent segment search, in milliseconds. $ref: '#/components/schemas/_common:DurationValueUnitMillis' concurrent_query_current: - description: The number of currently running query operations that use concurrent segment search. + description: The number of currently running query operations using concurrent segment search. type: number concurrent_avg_slice_count: description: The average slice count of all search requests. This is computed as the total slice count divided by the total number of concurrent search requests. type: number fetch_current: - description: The number of shard fetch operations that are currently running. + description: The number of currently running shard fetch operations. type: number fetch_time: - description: The total amount of time for all shard fetch operations. + description: The total amount of time taken to complete all shard fetch operations. $ref: '#/components/schemas/_common:Duration' fetch_time_in_millis: - description: The total amount of time for all shard fetch operations, in milliseconds. + description: The total amount of time taken to complete all shard fetch operations, in milliseconds. $ref: '#/components/schemas/_common:DurationValueUnitMillis' fetch_total: description: The total number of shard fetch operations. @@ -31204,16 +31803,16 @@ components: description: The number of shard scroll operations that are currently running. type: number scroll_time: - description: The total amount of time for all shard scroll operations. + description: The total amount of time taken to complete all shard scroll operations. $ref: '#/components/schemas/_common:Duration' scroll_time_in_millis: - description: The total amount of time for all shard scroll operations, in milliseconds. + description: The total amount of time taken to complete all shard scroll operations, in milliseconds. $ref: '#/components/schemas/_common:DurationValueUnitMillis' scroll_total: description: The total number of shard scroll operations. type: number point_in_time_total: - description: The total number of shard Point in Time (PIT) contexts that have been created (completed and active) since the node last restarted. + description: The total number of shard Point in Time (PIT) contexts created (completed and active) since the node last restarted. type: number point_in_time_time: $ref: '#/components/schemas/_common:Duration' @@ -31221,16 +31820,16 @@ components: description: The amount of time that shard PIT contexts have been held open since the node last restarted, in milliseconds. $ref: '#/components/schemas/_common:DurationValueUnitMillis' point_in_time_current: - description: The number of shard PIT contexts currently open. + description: The number of currently open shard PIT contexts. type: number suggest_current: - description: The number of shard suggest operations that are currently running. + description: The number of currently running shard suggest operations. type: number suggest_time: - description: The total amount of time for all shard suggest operations. + description: The total amount of time take to complete all shard suggest operations. $ref: '#/components/schemas/_common:Duration' suggest_time_in_millis: - description: The total amount of time for all shard suggest operations, in milliseconds. + description: The total amount of time taken to complete all shard suggest operations, in milliseconds. $ref: '#/components/schemas/_common:DurationValueUnitMillis' suggest_total: description: The total number of shard suggest operations. @@ -31239,7 +31838,7 @@ components: type: number request: type: object - description: Statistics about coordinator search operations for the node. + description: Statistics related to coordinator search operations for the node. additionalProperties: $ref: '#/components/schemas/_common:RequestStats' groups: @@ -31281,12 +31880,12 @@ components: type: object properties: count: - description: Total number of segments across all shards assigned to selected nodes. + description: The total number of segments across all shards assigned to the selected nodes. type: number doc_values_memory: $ref: '#/components/schemas/_common:HumanReadableByteCount' doc_values_memory_in_bytes: - description: Total amount, in bytes, of memory used for doc values across all shards assigned to selected nodes. + description: The total amount, in bytes, of memory used for document values across all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:ByteCount' file_sizes: description: |- @@ -31298,59 +31897,59 @@ components: fixed_bit_set: $ref: '#/components/schemas/_common:HumanReadableByteCount' fixed_bit_set_memory_in_bytes: - description: Total amount of memory, in bytes, used by fixed bit sets across all shards assigned to selected nodes. + description: The total amount of memory, in bytes, used by fixed bit sets across all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:ByteCount' index_writer_memory: $ref: '#/components/schemas/_common:HumanReadableByteCount' index_writer_max_memory_in_bytes: $ref: '#/components/schemas/_common:ByteCount' index_writer_memory_in_bytes: - description: Total amount, in bytes, of memory used by all index writers across all shards assigned to selected nodes. + description: The total amount, in bytes, of memory used by all index writers across all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:ByteCount' max_unsafe_auto_id_timestamp: - description: Unix timestamp, in milliseconds, of the most recently retried indexing request. + description: The Unix timestamp, in milliseconds, of the most recently retried indexing request. type: number memory: - description: Total amount, of memory used for segments across all shards assigned to selected nodes. + description: The total amount of memory used for segments across all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:HumanReadableByteCount' memory_in_bytes: - description: Total amount, in bytes, of memory used for segments across all shards assigned to selected nodes. + description: The total amount, in bytes, of memory used for segments across all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:ByteCount' norms_memory: - description: Total amount of memory used for normalization factors across all shards assigned to selected nodes. + description: The total amount of memory used for normalization factors across all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:HumanReadableByteCount' norms_memory_in_bytes: - description: Total amount, in bytes, of memory used for normalization factors across all shards assigned to selected nodes. + description: The total amount, in bytes, of memory used for normalization factors across all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:ByteCount' points_memory: - description: Total amount of memory used for points across all shards assigned to selected nodes. + description: The total amount of memory used for points across all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:HumanReadableByteCount' points_memory_in_bytes: - description: Total amount, in bytes, of memory used for points across all shards assigned to selected nodes. + description: The total amount, in bytes, of memory used for points across all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:ByteCount' stored_fields_memory: - description: Total amount of memory used for stored fields across all shards assigned to selected nodes. + description: The total amount of memory used for stored fields across all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:HumanReadableByteCount' stored_fields_memory_in_bytes: - description: Total amount, in bytes, of memory used for stored fields across all shards assigned to selected nodes. + description: The total amount, in bytes, of memory used for stored fields across all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:ByteCount' terms_memory: - description: Total amount of memory used for terms across all shards assigned to selected nodes. + description: The total amount of memory used for terms across all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:HumanReadableByteCount' terms_memory_in_bytes: - description: Total amount, in bytes, of memory used for terms across all shards assigned to selected nodes. + description: The total amount, in bytes, of memory used for terms across all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:ByteCount' term_vectors_memory: - description: Total amount of memory used for term vectors across all shards assigned to selected nodes. + description: The total amount of memory used for term vectors across all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:HumanReadableByteCount' term_vectors_memory_in_bytes: - description: Total amount, in bytes, of memory used for term vectors across all shards assigned to selected nodes. + description: The total amount, in bytes, of memory used for term vectors across all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:ByteCount' version_map_memory: - description: Total amount of memory used by all version maps across all shards assigned to selected nodes. + description: The total amount of memory used by all version maps across all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:HumanReadableByteCount' version_map_memory_in_bytes: - description: Total amount, in bytes, of memory used by all version maps across all shards assigned to selected nodes. + description: The total amount, in bytes, of memory used by all version maps across all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:ByteCount' remote_store: $ref: '#/components/schemas/_common:RemoteStoreStats' @@ -31425,12 +32024,13 @@ components: id: $ref: '#/components/schemas/_common:Id' max: - type: number + type: integer + format: int32 required: - id - max _common:Slices: - description: Slices configuration used to parallelize a process. + description: The slice configuration used to parallelize a process. oneOf: - type: number - $ref: '#/components/schemas/_common:SlicesCalculation' @@ -31446,9 +32046,12 @@ components: $ref: '#/components/schemas/_common:SortCombinations' _common:SortCombinations: oneOf: - - $ref: '#/components/schemas/_common:Field' - - $ref: '#/components/schemas/_common:FieldWithOrder' - - $ref: '#/components/schemas/_common:SortOptions' + - title: field + $ref: '#/components/schemas/_common:Field' + - title: field_with_order + $ref: '#/components/schemas/_common:FieldWithOrder' + - title: options + $ref: '#/components/schemas/_common:SortOptions' _common:SortMode: type: string enum: @@ -31509,7 +32112,7 @@ components: size: $ref: '#/components/schemas/_common:HumanReadableByteCount' size_in_bytes: - description: Total size, in bytes, of all shards assigned to selected nodes. + description: The total size, in bytes, of all shards assigned to the selected nodes. $ref: '#/components/schemas/_common:ByteCount' reserved: $ref: '#/components/schemas/_common:HumanReadableByteCount' @@ -31521,8 +32124,8 @@ components: - size_in_bytes _common:Stringifiedboolean: description: |- - Some APIs will return values such as numbers also as a string (notably epoch timestamps). This behavior - is used to capture this behavior while keeping the semantics of the field type. + Certain APIs may return values, including numbers such as epoch timestamps, as strings. This setting captures + this behavior while keeping the semantics of the field type. Depending on the target language, code generators can keep the union or remove it and leniently parse strings to the target type. @@ -31531,8 +32134,8 @@ components: - type: string _common:StringifiedEpochTimeUnitMillis: description: |- - Some APIs will return values such as numbers also as a string (notably epoch timestamps). This behavior - is used to capture this behavior while keeping the semantics of the field type. + Certain APIs may return values, including numbers such as epoch timestamps, as strings. This setting captures + this behavior while keeping the semantics of the field type. Depending on the target language, code generators can keep the union or remove it and leniently parse strings to the target type. @@ -31541,8 +32144,8 @@ components: - type: string _common:StringifiedEpochTimeUnitSeconds: description: |- - Some APIs will return values such as numbers also as a string (notably epoch timestamps). This behavior - is used to capture this behavior while keeping the semantics of the field type. + Certain APIs may return values, including numbers such as epoch timestamps, as strings. This setting captures + this behavior while keeping the semantics of the field type. Depending on the target language, code generators can keep the union or remove it and leniently parse strings to the target type. @@ -31551,18 +32154,18 @@ components: - type: string _common:Stringifiedinteger: description: |- - Some APIs will return values such as numbers also as a string (notably epoch timestamps). This behavior - is used to capture this behavior while keeping the semantics of the field type. + Certain APIs may return values, including numbers such as epoch timestamps, as strings. This setting captures + this behavior while keeping the semantics of the field type. Depending on the target language, code generators can keep the union or remove it and leniently parse strings to the target type. oneOf: - - type: number + - type: integer - type: string _common:StringifiedVersionNumber: description: |- - Some APIs will return values such as numbers also as a string (notably epoch timestamps). This behavior - is used to capture this behavior while keeping the semantics of the field type. + Certain APIs may return values, including numbers such as epoch timestamps, as strings. This setting captures + this behavior while keeping the semantics of the field type. Depending on the target language, code generators can keep the union or remove it and leniently parse strings to the target type. @@ -31595,6 +32198,14 @@ components: oneOf: - type: string - type: number + _common:TermFrequencyNormalization: + type: string + enum: + - h1 + - h2 + - h3 + - 'no' + - z _common:TimeOfDay: description: Time of day, expressed as HH:MM:SS. type: string @@ -31665,7 +32276,7 @@ components: _common:ulong: type: number _common:UnitMillis: - description: Time unit for milliseconds. + description: The time unit for milliseconds. type: integer format: int64 _common:UnitNanos: @@ -31674,7 +32285,8 @@ components: format: int64 _common:UnitSeconds: description: Time unit for seconds. - type: number + type: integer + format: int64 _common:Username: type: string _common:Uuid: @@ -31695,8 +32307,8 @@ components: description: |- The absence of any type. This is commonly used in APIs that don't return a body. - Although "void" is generally used for the unit type that has only one value, this is to be interpreted as - the bottom type that has no value at all. Most languages have a unit type, but few have a bottom type. + Although "void" is generally used for a unit type that has only one value, this is interpreted as + the bottom type, which has no value. Most languages have a unit type, but few have a bottom type. See https://en.m.wikipedia.org/wiki/Unit_type and https://en.m.wikipedia.org/wiki/Bottom_type. type: object @@ -31707,8 +32319,10 @@ components: - index-setting _common:WaitForActiveShards: oneOf: - - type: number - - $ref: '#/components/schemas/_common:WaitForActiveShardOptions' + - title: count + type: integer + - title: option + $ref: '#/components/schemas/_common:WaitForActiveShardOptions' _common:WaitForEvents: type: string enum: @@ -31777,25 +32391,31 @@ components: x: description: The x coordinate. type: number - y: + format: double + 'y': description: The y coordinate. type: number + format: double required: - x - - y + - 'y' _common:XyLocation: x-version-added: '2.4' description: |- - A two-dimensional Cartesian point specified by x and y coordinates. It can be represented in various ways: - - as a `{x, y}` object - - as a `[x, y]` array - - as a string in `"x, y"` or WKT point formats. + A two-dimensional Cartesian point specified by x and y coordinates. It can be represented in the following ways: + - As an `{x, y}` object. + - As an `[x, y]` array. + - As a string in `"x, y"` or WKT point format. oneOf: - - $ref: '#/components/schemas/_common:XyCartesianCoordinates' - - type: array + - title: cartesian + $ref: '#/components/schemas/_common:XyCartesianCoordinates' + - title: coords + type: array items: type: number - - type: string + format: double + - title: text + type: string _common.aggregations:AdjacencyMatrixAggregate: allOf: - $ref: '#/components/schemas/_common.aggregations:MultiBucketAggregateBaseAdjacencyMatrixBucket' @@ -31822,7 +32442,7 @@ components: required: - key _common.aggregations:Aggregate: - oneOf: + anyOf: - $ref: '#/components/schemas/_common.aggregations:CardinalityAggregate' - $ref: '#/components/schemas/_common.aggregations:HdrPercentilesAggregate' - $ref: '#/components/schemas/_common.aggregations:HdrPercentileRanksAggregate' @@ -34296,8 +34916,11 @@ components: type: boolean _common.aggregations:NestedAggregate: allOf: - - $ref: '#/components/schemas/_common.aggregations:SingleBucketAggregateBase' + - $ref: '#/components/schemas/_common.aggregations:AggregateBase' - type: object + properties: + doc_count: + type: number _common.aggregations:NestedAggregation: allOf: - $ref: '#/components/schemas/_common.aggregations:BucketAggregationBase' @@ -35409,6 +36032,8 @@ components: - $ref: '#/components/schemas/_common.analysis:KuromojiAnalyzer' - $ref: '#/components/schemas/_common.analysis:SnowballAnalyzer' - $ref: '#/components/schemas/_common.analysis:DutchAnalyzer' + - $ref: '#/components/schemas/_common.analysis:SmartcnAnalyzer' + - $ref: '#/components/schemas/_common.analysis:CjkAnalyzer' _common.analysis:AsciiFoldingTokenFilter: allOf: - $ref: '#/components/schemas/_common.analysis:TokenFilterBase' @@ -35424,8 +36049,10 @@ components: - type _common.analysis:CharFilter: oneOf: - - type: string - - $ref: '#/components/schemas/_common.analysis:CharFilterDefinition' + - title: name + type: string + - title: definition + $ref: '#/components/schemas/_common.analysis:CharFilterDefinition' _common.analysis:CharFilterBase: type: object properties: @@ -35455,10 +36082,21 @@ components: items: type: string max_token_length: - type: number + type: integer required: - tokenize_on_chars - type + _common.analysis:CjkAnalyzer: + type: object + properties: + type: + type: string + enum: + - cjk + stopwords: + $ref: '#/components/schemas/_common.analysis:StopWords' + stopwords_path: + type: string _common.analysis:CommonGramsTokenFilter: allOf: - $ref: '#/components/schemas/_common.analysis:TokenFilterBase' @@ -35488,11 +36126,11 @@ components: hyphenation_patterns_path: type: string max_subword_size: - type: number + type: integer min_subword_size: - type: number + type: integer min_word_size: - type: number + type: integer only_longest_match: type: boolean word_list: @@ -35536,9 +36174,9 @@ components: items: type: string position_increment_gap: - type: number + type: integer position_offset_gap: - type: number + type: integer tokenizer: type: string required: @@ -35619,9 +36257,9 @@ components: enum: - edge_ngram max_gram: - type: number + type: integer min_gram: - type: number + type: integer side: $ref: '#/components/schemas/_common.analysis:EdgeNGramSide' preserve_original: @@ -35640,9 +36278,9 @@ components: custom_token_chars: type: string max_gram: - type: number + type: integer min_gram: - type: number + type: integer token_chars: type: array items: @@ -35681,7 +36319,7 @@ components: version: $ref: '#/components/schemas/_common:VersionString' max_output_size: - type: number + type: integer preserve_original: type: boolean separator: @@ -35705,7 +36343,7 @@ components: enum: - fingerprint max_output_size: - type: number + type: integer separator: type: string required: @@ -35780,8 +36418,8 @@ components: _common.analysis:IcuCollationDecomposition: type: string enum: - - identical - - no + - canonical + - 'no' _common.analysis:IcuCollationStrength: type: string enum: @@ -35997,7 +36635,7 @@ components: enum: - keyword buffer_size: - type: number + type: integer required: - buffer_size - type @@ -36083,7 +36721,7 @@ components: enum: - kuromoji_stemmer minimum_length: - type: number + type: integer required: - minimum_length - type @@ -36107,7 +36745,7 @@ components: mode: $ref: '#/components/schemas/_common.analysis:KuromojiTokenizationMode' nbest_cost: - type: number + type: integer nbest_examples: type: string user_dictionary: @@ -36191,9 +36829,9 @@ components: enum: - length max: - type: number + type: integer min: - type: number + type: integer required: - type _common.analysis:LetterTokenizer: @@ -36300,9 +36938,9 @@ components: enum: - ngram max_gram: - type: number + type: integer min_gram: - type: number + type: integer preserve_original: $ref: '#/components/schemas/_common:Stringifiedboolean' required: @@ -36319,9 +36957,9 @@ components: custom_token_chars: type: string max_gram: - type: number + type: integer min_gram: - type: number + type: integer token_chars: type: array items: @@ -36512,11 +37150,22 @@ components: flags: type: string group: - type: number + type: integer pattern: type: string required: - type + _common.analysis:PersianStemTokenFilter: + allOf: + - $ref: '#/components/schemas/_common.analysis:TokenFilterBase' + - type: object + properties: + type: + type: string + enum: + - persian_stem + required: + - type _common.analysis:PhoneticEncoder: type: string enum: @@ -36574,7 +37223,7 @@ components: items: $ref: '#/components/schemas/_common.analysis:PhoneticLanguage' max_code_len: - type: number + type: integer name_type: $ref: '#/components/schemas/_common.analysis:PhoneticNameType' replace: @@ -36672,6 +37321,35 @@ components: $ref: '#/components/schemas/_common:VersionString' required: - type + _common.analysis:SmartcnAnalyzer: + type: object + properties: + type: + type: string + enum: + - smartcn + _common.analysis:SmartcnStopTokenFilter: + allOf: + - $ref: '#/components/schemas/_common.analysis:TokenFilterBase' + - type: object + properties: + type: + type: string + enum: + - smartcn_stop + required: + - type + _common.analysis:SmartcnTokenizer: + allOf: + - $ref: '#/components/schemas/_common.analysis:TokenizerBase' + - type: object + properties: + type: + type: string + enum: + - smartcn_tokenizer + required: + - type _common.analysis:SnowballAnalyzer: type: object properties: @@ -36735,7 +37413,7 @@ components: enum: - standard max_token_length: - type: number + type: integer stopwords: $ref: '#/components/schemas/_common.analysis:StopWords' required: @@ -36750,7 +37428,7 @@ components: enum: - standard max_token_length: - type: number + type: integer required: - type _common.analysis:StemmerOverrideTokenFilter: @@ -36897,8 +37575,10 @@ components: - whitespace _common.analysis:TokenFilter: oneOf: - - type: string - - $ref: '#/components/schemas/_common.analysis:TokenFilterDefinition' + - title: name + type: string + - title: definition + $ref: '#/components/schemas/_common.analysis:TokenFilterDefinition' _common.analysis:TokenFilterBase: type: object properties: @@ -36930,6 +37610,7 @@ components: - $ref: '#/components/schemas/_common.analysis:NoriPartOfSpeechTokenFilter' - $ref: '#/components/schemas/_common.analysis:PatternCaptureTokenFilter' - $ref: '#/components/schemas/_common.analysis:PatternReplaceTokenFilter' + - $ref: '#/components/schemas/_common.analysis:PersianStemTokenFilter' - $ref: '#/components/schemas/_common.analysis:PorterStemTokenFilter' - $ref: '#/components/schemas/_common.analysis:PredicateTokenFilter' - $ref: '#/components/schemas/_common.analysis:RemoveDuplicatesTokenFilter' @@ -36957,10 +37638,13 @@ components: - $ref: '#/components/schemas/_common.analysis:IcuTransformTokenFilter' - $ref: '#/components/schemas/_common.analysis:PhoneticTokenFilter' - $ref: '#/components/schemas/_common.analysis:DictionaryDecompounderTokenFilter' + - $ref: '#/components/schemas/_common.analysis:SmartcnStopTokenFilter' _common.analysis:Tokenizer: oneOf: - - type: string - - $ref: '#/components/schemas/_common.analysis:TokenizerDefinition' + - title: name + type: string + - title: definition + $ref: '#/components/schemas/_common.analysis:TokenizerDefinition' _common.analysis:TokenizerBase: type: object properties: @@ -36985,6 +37669,7 @@ components: - $ref: '#/components/schemas/_common.analysis:KuromojiTokenizer' - $ref: '#/components/schemas/_common.analysis:PatternTokenizer' - $ref: '#/components/schemas/_common.analysis:IcuTokenizer' + - $ref: '#/components/schemas/_common.analysis:SmartcnTokenizer' _common.analysis:TrimTokenFilter: allOf: - $ref: '#/components/schemas/_common.analysis:TokenFilterBase' @@ -37006,7 +37691,7 @@ components: enum: - truncate length: - type: number + type: integer required: - type _common.analysis:UaxEmailUrlTokenizer: @@ -37019,7 +37704,7 @@ components: enum: - uax_url_email max_token_length: - type: number + type: integer required: - type _common.analysis:UniqueTokenFilter: @@ -37067,7 +37752,7 @@ components: enum: - whitespace max_token_length: - type: number + type: integer required: - type _common.analysis:WordDelimiterGraphTokenFilter: @@ -37229,6 +37914,7 @@ components: properties: boost: type: number + format: double fielddata: $ref: '#/components/schemas/indices._common:NumericFielddata' index: @@ -37266,7 +37952,7 @@ components: items: $ref: '#/components/schemas/_common.mapping:SuggestContext' max_input_length: - type: number + type: integer preserve_position_increments: type: boolean preserve_separators: @@ -37284,8 +37970,7 @@ components: - $ref: '#/components/schemas/_common.mapping:PropertyBase' - type: object properties: - value: - type: object + value: {} type: type: string enum: @@ -37317,6 +38002,7 @@ components: properties: boost: type: number + format: double format: type: string ignore_malformed: @@ -37326,7 +38012,7 @@ components: null_value: $ref: '#/components/schemas/_common:DateTime' precision_step: - type: number + type: integer type: type: string enum: @@ -37340,6 +38026,7 @@ components: properties: boost: type: number + format: double fielddata: $ref: '#/components/schemas/indices._common:NumericFielddata' format: @@ -37351,7 +38038,7 @@ components: null_value: $ref: '#/components/schemas/_common:DateTime' precision_step: - type: number + type: integer locale: type: string type: @@ -37424,6 +38111,7 @@ components: - double null_value: type: number + format: double required: - type _common.mapping:DoubleRangeProperty: @@ -37444,61 +38132,6 @@ components: - strict - strict_allow_templates - 'true' - _common.mapping:DynamicProperty: - allOf: - - $ref: '#/components/schemas/_common.mapping:DocValuesPropertyBase' - - type: object - properties: - type: - type: string - enum: - - '{dynamic_property}' - enabled: - type: boolean - null_value: - $ref: '#/components/schemas/_common:FieldValue' - boost: - type: number - coerce: - type: boolean - script: - $ref: '#/components/schemas/_common:Script' - on_script_error: - $ref: '#/components/schemas/_common.mapping:OnScriptError' - ignore_malformed: - type: boolean - time_series_metric: - $ref: '#/components/schemas/_common.mapping:TimeSeriesMetricType' - analyzer: - type: string - eager_global_ordinals: - type: boolean - index: - type: boolean - index_options: - $ref: '#/components/schemas/_common.mapping:IndexOptions' - index_phrases: - type: boolean - index_prefixes: - $ref: '#/components/schemas/_common.mapping:TextIndexPrefixes' - norms: - type: boolean - position_increment_gap: - type: number - search_analyzer: - type: string - search_quote_analyzer: - type: string - term_vector: - $ref: '#/components/schemas/_common.mapping:TermVectorOption' - format: - type: string - precision_step: - type: number - locale: - type: string - required: - - type _common.mapping:DynamicTemplate: type: object properties: @@ -37557,6 +38190,7 @@ components: properties: boost: type: number + format: double depth_limit: type: number doc_values: @@ -37590,6 +38224,7 @@ components: - float null_value: type: number + format: float required: - type _common.mapping:FloatRangeProperty: @@ -37604,10 +38239,21 @@ components: required: - type _common.mapping:GeoOrientation: - type: string - enum: - - left - - right + oneOf: + - title: left + type: string + enum: + - LEFT + - clockwise + - cw + - left + - title: right + type: string + enum: + - RIGHT + - ccw + - counterclockwise + - right _common.mapping:GeoPointProperty: allOf: - $ref: '#/components/schemas/_common.mapping:DocValuesPropertyBase' @@ -37643,6 +38289,7 @@ components: deprecated: true distance_error_pct: type: number + format: double deprecated: true type: type: string @@ -37666,6 +38313,7 @@ components: - half_float null_value: type: number + format: float required: - type _common.mapping:HistogramProperty: @@ -37705,7 +38353,7 @@ components: enum: - integer null_value: - type: number + type: integer required: - type _common.mapping:IntegerRangeProperty: @@ -37726,6 +38374,7 @@ components: properties: boost: type: number + format: double index: type: boolean ignore_malformed: @@ -37784,6 +38433,7 @@ components: properties: boost: type: number + format: double eager_global_ordinals: type: boolean index: @@ -37818,30 +38468,35 @@ components: type: string parameters: type: object - additionalProperties: - type: object + additionalProperties: {} required: - name _common.mapping:KnnVectorProperty: allOf: - - $ref: '#/components/schemas/_common.mapping:KnnVectorPropertyBase' + - $ref: '#/components/schemas/_common.mapping:DocValuesPropertyBase' - type: object properties: type: type: string enum: - knn_vector + dimension: + type: integer + space_type: + type: string + data_type: + type: string + mode: + type: string + compression_level: + type: string + method: + $ref: '#/components/schemas/_common.mapping:KnnVectorMethod' + model_id: + type: string required: + - dimension - type - _common.mapping:KnnVectorPropertyBase: - type: object - properties: - dimension: - type: number - method: - $ref: '#/components/schemas/_common.mapping:KnnVectorMethod' - required: - - dimension _common.mapping:LongNumberProperty: allOf: - $ref: '#/components/schemas/_common.mapping:NumberPropertyBase' @@ -37852,7 +38507,8 @@ components: enum: - long null_value: - type: number + type: integer + format: int64 required: - type _common.mapping:LongRangeProperty: @@ -37929,6 +38585,7 @@ components: properties: boost: type: number + format: double coerce: type: boolean ignore_malformed: @@ -37978,7 +38635,6 @@ components: oneOf: - $ref: '#/components/schemas/_common.mapping:BinaryProperty' - $ref: '#/components/schemas/_common.mapping:BooleanProperty' - - $ref: '#/components/schemas/_common.mapping:DynamicProperty' - $ref: '#/components/schemas/_common.mapping:JoinProperty' - $ref: '#/components/schemas/_common.mapping:KeywordProperty' - $ref: '#/components/schemas/_common.mapping:MatchOnlyTextProperty' @@ -38037,7 +38693,7 @@ components: additionalProperties: $ref: '#/components/schemas/_common.mapping:Property' ignore_above: - type: number + type: integer dynamic: $ref: '#/components/schemas/_common.mapping:DynamicMapping' fields: @@ -38051,6 +38707,7 @@ components: properties: boost: type: number + format: double coerce: type: boolean index: @@ -38086,53 +38743,6 @@ components: type: boolean required: - required - _common.mapping:RuntimeField: - type: object - properties: - fetch_fields: - description: For type `lookup` - type: array - items: - $ref: '#/components/schemas/_common.mapping:RuntimeFieldFetchFields' - format: - description: A custom format for `date` type runtime fields. - type: string - input_field: - $ref: '#/components/schemas/_common:Field' - target_field: - $ref: '#/components/schemas/_common:Field' - target_index: - $ref: '#/components/schemas/_common:IndexName' - script: - $ref: '#/components/schemas/_common:Script' - type: - $ref: '#/components/schemas/_common.mapping:RuntimeFieldType' - required: - - type - _common.mapping:RuntimeFieldFetchFields: - type: object - properties: - field: - $ref: '#/components/schemas/_common:Field' - format: - type: string - required: - - field - _common.mapping:RuntimeFields: - type: object - additionalProperties: - $ref: '#/components/schemas/_common.mapping:RuntimeField' - _common.mapping:RuntimeFieldType: - type: string - enum: - - boolean - - date - - double - - geo_point - - ip - - keyword - - long - - lookup _common.mapping:ScaledFloatNumberProperty: allOf: - $ref: '#/components/schemas/_common.mapping:NumberPropertyBase' @@ -38144,8 +38754,10 @@ components: - scaled_float null_value: type: number + format: double scaling_factor: type: number + format: double required: - type _common.mapping:SearchAsYouTypeProperty: @@ -38160,7 +38772,7 @@ components: index_options: $ref: '#/components/schemas/_common.mapping:IndexOptions' max_shingle_size: - type: number + type: integer norms: type: boolean search_analyzer: @@ -38212,14 +38824,6 @@ components: type: array items: type: string - mode: - $ref: '#/components/schemas/_common.mapping:SourceFieldMode' - _common.mapping:SourceFieldMode: - type: string - enum: - - disabled - - stored - - synthetic _common.mapping:SparseVectorProperty: allOf: - $ref: '#/components/schemas/_common.mapping:PropertyBase' @@ -38250,20 +38854,20 @@ components: _common.mapping:TermVectorOption: type: string enum: - - no + - 'no' - with_offsets - with_positions - with_positions_offsets - with_positions_offsets_payloads - with_positions_payloads - - yes + - 'yes' _common.mapping:TextIndexPrefixes: type: object properties: max_chars: - type: number + type: integer min_chars: - type: number + type: integer required: - max_chars - min_chars @@ -38276,6 +38880,7 @@ components: type: string boost: type: number + format: double eager_global_ordinals: type: boolean fielddata: @@ -38293,7 +38898,7 @@ components: norms: type: boolean position_increment_gap: - type: number + type: integer search_analyzer: type: string search_quote_analyzer: @@ -38323,10 +38928,12 @@ components: type: string boost: type: number + format: double index: type: boolean null_value: type: number + format: double enable_position_increments: type: boolean type: @@ -38372,10 +38979,6 @@ components: $ref: '#/components/schemas/_common.mapping:SizeField' _source: $ref: '#/components/schemas/_common.mapping:SourceField' - runtime: - type: object - additionalProperties: - $ref: '#/components/schemas/_common.mapping:RuntimeField' enabled: type: boolean _data_stream_timestamp: @@ -38494,6 +39097,13 @@ components: - type: array items: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' + adjust_pure_negative: + description: |- + Ensures correct behavior when a query contains only must_not clauses. + By default set to true, OpenSearch adds a match-all clause to ensure results are returned from Lucene, with the must_not conditions applied as filters. + If set to false, the query may return no results, as Lucene typically requires at least one positive condition. + type: boolean + default: true _common.query_dsl:BoostingQuery: allOf: - $ref: '#/components/schemas/_common.query_dsl:QueryBase' @@ -38502,6 +39112,7 @@ components: negative_boost: description: Floating point number between 0 and 1.0 used to decrease the relevance scores of documents matching the `negative` query. type: number + format: float negative: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' positive: @@ -38564,6 +39175,7 @@ components: type: string cutoff_frequency: type: number + format: float high_freq_operator: $ref: '#/components/schemas/_common.query_dsl:Operator' low_freq_operator: @@ -38642,6 +39254,7 @@ components: tie_breaker: description: Floating point number between 0 and 1.0 used to increase the relevance scores of documents matching multiple query clauses. type: number + format: float required: - queries _common.query_dsl:DistanceFeatureQuery: @@ -38720,11 +39333,13 @@ components: factor: description: Optional factor to multiply the field value with. type: number + format: float missing: description: |- Value used if the document doesn't have that field. The modifier and factor are still applied to it as though it were read from the document. type: number + format: double modifier: $ref: '#/components/schemas/_common.query_dsl:FieldValueFactorModifier' required: @@ -38746,6 +39361,7 @@ components: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' weight: type: number + format: float - type: object properties: exp: @@ -38786,9 +39402,11 @@ components: max_boost: description: Restricts the new score to not exceed the provided limit. type: number + format: float min_score: description: Excludes documents that do not meet the provided score threshold. type: number + format: float query: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' score_mode: @@ -38800,10 +39418,12 @@ components: properties: max_expansions: description: Maximum number of variations created. - type: number + type: integer + format: int32 prefix_length: description: Number of beginning characters left unchanged when creating expansions. - type: number + type: integer + format: int32 rewrite: $ref: '#/components/schemas/_common:MultiTermQueryRewrite' transpositions: @@ -38919,12 +39539,14 @@ components: description: |- Maximum number of child documents that match the query allowed for a returned parent document. If the parent document exceeds this limit, it is excluded from the search results. - type: number + type: integer + format: int32 min_children: description: |- Minimum number of child documents that match the query required to match the query for a returned parent document. If the parent document does not meet this limit, it is excluded from the search results. - type: number + type: integer + format: int32 query: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' score_mode: @@ -38981,7 +39603,8 @@ components: description: |- Maximum number of positions between the matching terms. Intervals produced by the rules further apart than this are not considered matches. - type: number + type: integer + format: int32 ordered: description: If `true`, intervals produced by the rules should appear in the order in which they are specified. type: boolean @@ -39051,7 +39674,8 @@ components: $ref: '#/components/schemas/_common:Fuzziness' prefix_length: description: Number of beginning characters left unchanged when creating expansions. - type: number + type: integer + format: int32 term: description: The term to match. type: string @@ -39072,7 +39696,8 @@ components: description: |- Maximum number of positions between the matching terms. Terms further apart than this are not considered matches. - type: number + type: integer + format: int32 ordered: description: If `true`, matching terms must appear in their specified order. type: boolean @@ -39190,7 +39815,8 @@ components: description: |- Maximum number of terms to which the query will expand. Can be applied to the term subqueries constructed for all terms but the final term. - type: number + type: integer + format: int32 minimum_should_match: $ref: '#/components/schemas/_common:MinimumShouldMatch' operator: @@ -39199,7 +39825,8 @@ components: description: |- Number of beginning characters left unchanged for fuzzy matching. Can be applied to the term subqueries constructed for all terms but the final term. - type: number + type: integer + format: int32 query: description: |- Terms you wish to find in the provided field. @@ -39221,13 +39848,15 @@ components: type: string max_expansions: description: Maximum number of terms to which the last provided term of the query value will expand. - type: number + type: integer + format: int32 query: description: Text you wish to find in the provided field. type: string slop: description: Maximum number of positions allowed between matching tokens. - type: number + type: integer + format: int32 zero_terms_query: $ref: '#/components/schemas/_common.query_dsl:ZeroTermsQuery' required: @@ -39245,7 +39874,8 @@ components: type: string slop: description: Maximum number of positions allowed between matching tokens. - type: number + type: integer + format: int32 zero_terms_query: $ref: '#/components/schemas/_common.query_dsl:ZeroTermsQuery' required: @@ -39264,6 +39894,7 @@ components: cutoff_frequency: deprecated: true type: number + format: float fuzziness: $ref: '#/components/schemas/_common:Fuzziness' fuzzy_rewrite: @@ -39276,14 +39907,16 @@ components: type: boolean max_expansions: description: Maximum number of terms to which the query will expand. - type: number + type: integer + format: int32 minimum_should_match: $ref: '#/components/schemas/_common:MinimumShouldMatch' operator: $ref: '#/components/schemas/_common.query_dsl:Operator' prefix_length: description: Number of beginning characters left unchanged for fuzzy matching. - type: number + type: integer + format: int32 query: description: Text, number, boolean value or date you wish to find in the provided field. oneOf: @@ -39310,6 +39943,7 @@ components: This sets the boost factor to use when using this feature. Defaults to deactivated (0). type: number + format: float fail_on_unsupported_field: description: Controls whether the query should fail (throw an exception) if any of the specified fields are not of the supported types (`text` or `keyword`). type: boolean @@ -39332,26 +39966,32 @@ components: $ref: '#/components/schemas/_common.query_dsl:Like' max_doc_freq: description: The maximum document frequency above which the terms are ignored from the input document. - type: number + type: integer + format: int32 max_query_terms: description: The maximum number of query terms that can be selected. - type: number + type: integer + format: int32 max_word_length: description: |- The maximum word length above which the terms are ignored. Defaults to unbounded (`0`). - type: number + type: integer + format: int32 min_doc_freq: description: The minimum document frequency below which the terms are ignored from the input document. - type: number + type: integer + format: int32 minimum_should_match: $ref: '#/components/schemas/_common:MinimumShouldMatch' min_term_freq: description: The minimum term frequency below which the terms are ignored from the input document. - type: number + type: integer + format: int32 min_word_length: description: The minimum word length below which the terms are ignored. - type: number + type: integer + format: int32 per_field_analyzer: description: Overrides the default analyzer. type: object @@ -39388,6 +40028,7 @@ components: cutoff_frequency: deprecated: true type: number + format: float fields: $ref: '#/components/schemas/_common:Fields' fuzziness: @@ -39404,23 +40045,27 @@ components: type: boolean max_expansions: description: Maximum number of terms to which the query will expand. - type: number + type: integer + format: int32 minimum_should_match: $ref: '#/components/schemas/_common:MinimumShouldMatch' operator: $ref: '#/components/schemas/_common.query_dsl:Operator' prefix_length: description: Number of beginning characters left unchanged for fuzzy matching. - type: number + type: integer + format: int32 query: description: Text, number, boolean value or date you wish to find in the provided field. type: string slop: description: Maximum number of positions allowed between matching tokens. - type: number + type: integer + format: int32 tie_breaker: description: Determines how scores for each per-term blended query and scores across groups are combined. type: number + format: float type: $ref: '#/components/schemas/_common.query_dsl:TextQueryType' zero_terms_query: @@ -39473,8 +40118,10 @@ components: type: integer min_score: type: number + format: float max_distance: type: number + format: float filter: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' _common.query_dsl:NumberRangeQuery: @@ -39621,6 +40268,7 @@ components: A boost value between 0 and 1.0 decreases the relevance score. A value greater than 1.0 increases the relevance score. type: number + format: float _name: type: string _common.query_dsl:QueryContainer: @@ -39877,10 +40525,12 @@ components: $ref: '#/components/schemas/_common:Fuzziness' fuzzy_max_expansions: description: Maximum number of terms to which the query expands for fuzzy matching. - type: number + type: integer + format: int32 fuzzy_prefix_length: description: Number of beginning characters left unchanged for fuzzy matching. - type: number + type: integer + format: int32 fuzzy_rewrite: $ref: '#/components/schemas/_common:MultiTermQueryRewrite' fuzzy_transpositions: @@ -39891,12 +40541,14 @@ components: type: boolean max_determinized_states: description: Maximum number of automaton states required for the query. - type: number + type: integer + format: int32 minimum_should_match: $ref: '#/components/schemas/_common:MinimumShouldMatch' phrase_slop: description: Maximum number of positions allowed between matching tokens for phrases. - type: number + type: integer + format: int32 query: description: Query string you wish to parse and use for search. type: string @@ -39915,6 +40567,7 @@ components: tie_breaker: description: How to combine the queries generated from the individual search terms in the resulting `dis_max` query. type: number + format: float time_zone: $ref: '#/components/schemas/_common:TimeZone' type: @@ -39928,7 +40581,8 @@ components: $ref: '#/components/schemas/_common:Field' seed: oneOf: - - type: number + - type: integer + format: int32 - type: string _common.query_dsl:RangeQuery: oneOf: @@ -39961,6 +40615,7 @@ components: scaling_factor: description: Configurable scaling factor. type: number + format: float required: - scaling_factor _common.query_dsl:RankFeatureFunctionSaturation: @@ -39971,6 +40626,7 @@ components: pivot: description: Configurable pivot value so that the result will be less than 0.5. type: number + format: float _common.query_dsl:RankFeatureFunctionSigmoid: allOf: - $ref: '#/components/schemas/_common.query_dsl:RankFeatureFunction' @@ -39979,9 +40635,11 @@ components: pivot: description: Configurable pivot value so that the result will be less than 0.5. type: number + format: float exponent: description: Configurable Exponent. type: number + format: float required: - exponent - pivot @@ -40017,7 +40675,8 @@ components: type: string max_determinized_states: description: Maximum number of automaton states required for the query. - type: number + type: integer + format: int32 rewrite: $ref: '#/components/schemas/_common:MultiTermQueryRewrite' value: @@ -40064,6 +40723,7 @@ components: min_score: description: Documents with a score lower than this floating point number are excluded from the search results. type: number + format: float query: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' script: @@ -40120,10 +40780,12 @@ components: $ref: '#/components/schemas/_common.query_dsl:SimpleQueryStringFlags' fuzzy_max_expansions: description: Maximum number of terms to which the query expands for fuzzy matching. - type: number + type: integer + format: int32 fuzzy_prefix_length: description: Number of beginning characters left unchanged for fuzzy matching. - type: number + type: integer + format: int32 fuzzy_transpositions: description: If `true`, edits for fuzzy matching include transpositions of two adjacent characters (for example, `ab` to `ba`). type: boolean @@ -40171,7 +40833,8 @@ components: properties: end: description: Controls the maximum end position permitted in a match. - type: number + type: integer + format: int32 match: $ref: '#/components/schemas/_common.query_dsl:SpanQuery' required: @@ -40181,7 +40844,8 @@ components: description: Can only be used as a clause in a span_near query. type: object additionalProperties: - type: number + type: integer + format: int32 minProperties: 1 maxProperties: 1 _common.query_dsl:SpanMultiTermQuery: @@ -40208,7 +40872,8 @@ components: type: boolean slop: description: Controls the maximum number of intervening unmatched positions permitted. - type: number + type: integer + format: int32 required: - clauses _common.query_dsl:SpanNotQuery: @@ -40220,17 +40885,20 @@ components: description: |- The number of tokens from within the include span that can't have overlap with the exclude span. Equivalent to setting both `pre` and `post`. - type: number + type: integer + format: int32 exclude: $ref: '#/components/schemas/_common.query_dsl:SpanQuery' include: $ref: '#/components/schemas/_common.query_dsl:SpanQuery' post: description: The number of tokens after the include span that can't have overlap with the exclude span. - type: number + type: integer + format: int32 pre: description: The number of tokens before the include span that can't have overlap with the exclude span. - type: number + type: integer + format: int32 required: - exclude - include @@ -40527,7 +41195,8 @@ components: routing: $ref: '#/components/schemas/_common:Routing' if_primary_term: - type: number + type: integer + format: int64 if_seq_no: $ref: '#/components/schemas/_common:SequenceNumber' version: @@ -40561,17 +41230,19 @@ components: - string _index: description: |- - Name of the index associated with the operation. - If the operation targeted a data stream, this is the backing index into which the document was written. + The name of the index associated with the operation. + If the operation targets a data stream, this is the backing index into which the document was written. type: string status: description: HTTP status code returned for the operation. - type: number + type: integer + format: int32 error: $ref: '#/components/schemas/_common:ErrorCause' _primary_term: description: The primary term assigned to the document for the operation. - type: number + type: integer + format: int64 result: description: |- Result of the operation. @@ -40595,19 +41266,19 @@ components: properties: detect_noop: description: |- - Set to false to disable setting 'result' in the response + When `false` disables the setting 'result' in the response to 'noop' if no change to the document occurred. type: boolean doc: description: A partial update to an existing document. type: object doc_as_upsert: - description: Set to true to use the contents of 'doc' as the value of 'upsert' + description: When `true`, uses the contents of 'doc' as the value of 'upsert'. type: boolean script: $ref: '#/components/schemas/_common:Script' scripted_upsert: - description: Set to true to execute the script whether or not the document exists. + description: When `true`, executes the script whether or not the document exists. type: boolean _source: $ref: '#/components/schemas/_core.search:SourceConfig' @@ -40622,10 +41293,11 @@ components: - type: object properties: require_alias: - description: If `true`, the request's actions must target an index alias. + description: When `true`, the request's actions must target an index alias. type: boolean retry_on_conflict: - type: number + type: integer + format: int32 _core.bulk:WriteOperation: allOf: - $ref: '#/components/schemas/_core.bulk:OperationBase' @@ -40634,7 +41306,6 @@ components: dynamic_templates: description: |- A map from the full name of fields to the name of dynamic templates. - Defaults to an empty map. If a name matches a dynamic template, then that template will be applied regardless of other match predicates defined in the template. If a field is already defined in the mapping, then this parameter won't be used. type: object @@ -40642,12 +41313,12 @@ components: type: string pipeline: description: |- - ID of the pipeline to use to preprocess incoming documents. - If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request. - If a final pipeline is configured it will always run, regardless of the value of this parameter. + The pipeline ID for preprocessing documents. + When the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request. + When a final pipeline is configured, that pipeline will always run, regardless of the value of this parameter. type: string require_alias: - description: If `true`, the request's actions must target an index alias. + description: When `true`, require that all actions target an index alias rather than an index. Default is `false`. type: boolean _core.explain:Explanation: type: object @@ -40659,7 +41330,15 @@ components: items: $ref: '#/components/schemas/_core.explain:ExplanationDetail' value: - type: number + oneOf: + - type: integer + format: int32 + - type: integer + format: int64 + - type: number + format: float + - type: number + format: double required: - description - details @@ -40674,7 +41353,15 @@ components: items: $ref: '#/components/schemas/_core.explain:ExplanationDetail' value: - type: number + oneOf: + - type: integer + format: int32 + - type: integer + format: int64 + - type: number + format: float + - type: number + format: double required: - description - value @@ -40682,7 +41369,7 @@ components: type: object properties: aggregatable: - description: Whether this field can be aggregated on all indices. + description: Whether this field can be aggregated on all indexes. type: boolean indices: $ref: '#/components/schemas/_common:Indices' @@ -40693,7 +41380,7 @@ components: non_searchable_indices: $ref: '#/components/schemas/_common:Indices' searchable: - description: Whether this field is indexed for search on all indices. + description: Whether this field is indexed for search on all indexes. type: boolean type: type: string @@ -40707,15 +41394,15 @@ components: $ref: '#/components/schemas/_common.mapping:TimeSeriesMetricType' non_dimension_indices: description: |- - If this list is present in response then some indices have the - field marked as a dimension and other indices, the ones in this list, do not. + If this list is present in the response, then indexes not contained in the list have the + field marked as a dimension. Any indexes contained in the list are not marked as a dimension. type: array items: $ref: '#/components/schemas/_common:IndexName' metric_conflicts_indices: description: |- - The list of indices where this field is present if these indices - don't have the same `time_series_metric` value for this field. + The list of indexes in which this field is present if the indexes + don't have the same `time_series_metric` value for the field. type: array items: $ref: '#/components/schemas/_common:IndexName' @@ -40845,25 +41532,25 @@ components: type: object properties: explain: - description: If `true`, returns detailed information about score calculation as part of each hit. + description: When `true`, returns detailed information about score calculation as part of each hit. type: boolean id: $ref: '#/components/schemas/_common:Id' params: description: |- - Key-value pairs used to replace Mustache variables in the template. + The key-value pairs used to replace Mustache variables in the template. The key is the variable name. The value is the variable value. type: object additionalProperties: type: object profile: - description: If `true`, the query execution is profiled. + description: When `true`, provides a profile for the query execution. type: boolean source: description: |- - An inline search template. Supports the same parameters as the search API's - request body. Also supports Mustache variables. If no id is specified, this + An inline search template that supports the same parameters as the Search API's + request body and Mustache variables. If no `id` is specified, this parameter is required. type: string _core.msearch:MultisearchBody: @@ -40878,10 +41565,10 @@ components: query: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' explain: - description: If true, returns detailed information about score computation as part of a hit. + description: When `true`, returns detailed information about score computation as part of a hit. type: boolean ext: - description: Configuration of search extensions defined by OpenSearch plugins. + description: The configuration of search extensions defined by OpenSearch plugins. type: object additionalProperties: type: object @@ -40889,8 +41576,8 @@ components: $ref: '#/components/schemas/_common:Fields' docvalue_fields: description: |- - Array of wildcard (*) patterns. The request returns doc values for field - names matching these patterns in the hits.fields property of the response. + An array of wildcard (*) patterns. The request returns document values for field + names matching these patterns in the `hits.fields` property of the response. type: array items: $ref: '#/components/schemas/_common.query_dsl:FieldAndFormat' @@ -40903,14 +41590,14 @@ components: $ref: '#/components/schemas/_common.query_dsl:KnnQuery' from: description: |- - Starting document offset. By default, you cannot page through more than 10,000 - hits using the from and size parameters. To page through more hits, use the - search_after parameter. + The starting document offset. By default, you cannot page through more than 10,000 + hits using the `from` and `size` parameters. To page through more than 10,000 hits, use the + `search_after` parameter. type: number highlight: $ref: '#/components/schemas/_core.search:Highlight' indices_boost: - description: Boosts the _score of documents from specified indices. + description: Boosts the `_score` of documents from the specified indexes. type: array items: type: object @@ -40918,8 +41605,8 @@ components: type: number min_score: description: |- - Minimum _score for matching documents. Documents with a lower _score are - not included in the search results. + The minimum `_score` for document matching. Documents with a lower `_score` than the minimum + are not included in the search results. type: number post_filter: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' @@ -40932,7 +41619,7 @@ components: items: $ref: '#/components/schemas/_core.search:Rescore' script_fields: - description: Retrieve a script evaluation (based on different fields) for each hit. + description: Retrieves a script evaluation (based on different fields) for each hit. type: object additionalProperties: $ref: '#/components/schemas/_common:ScriptField' @@ -40941,8 +41628,8 @@ components: size: description: |- The number of hits to return. By default, you cannot page through more - than 10,000 hits using the from and size parameters. To page through more - hits, use the search_after parameter. + than 10,000 hits using the `from` and `size` parameters. To page through more + hits, use the `search_after` parameter. type: number sort: $ref: '#/components/schemas/_common:Sort' @@ -40950,22 +41637,22 @@ components: $ref: '#/components/schemas/_core.search:SourceConfig' fields: description: |- - Array of wildcard (*) patterns. The request returns values for field names - matching these patterns in the hits.fields property of the response. + An array of wildcard (*) patterns. The request returns values for field names + matching these patterns in the `hits.fields` property of the response. type: array items: $ref: '#/components/schemas/_common.query_dsl:FieldAndFormat' terminate_after: description: |- - Maximum number of documents to collect for each shard. If a query reaches this - limit, OpenSearch terminates the query early. OpenSearch collects documents - before sorting. Defaults to 0, which does not terminate query execution early. + The maximum number of documents to collect for each shard. If a query reaches this + limit, OpenSearch stops the query early. OpenSearch collects documents + before sorting. Default is `0`, which does not terminate query execution early. type: number stats: description: |- - Stats groups to associate with the search. Each group maintains a statistics - aggregation for its associated searches. You can retrieve these stats using - the indices stats API. + The statistics groups to associate with the search. Each group maintains a statistics + aggregation for its associated searches. You can retrieve these statistics using + the Index Stats API. type: array items: type: string @@ -40973,21 +41660,19 @@ components: description: |- Specifies the period of time to wait for a response from each shard. If no response is received before the timeout expires, the request fails and returns an error. - Defaults to no timeout. + Default is no timeout. type: string track_scores: - description: If true, calculate and return document scores, even if the scores are not used for sorting. + description: When `true`, calculates and returns all document scores, even if the scores are not used for sorting. type: boolean track_total_hits: $ref: '#/components/schemas/_core.search:TrackHits' version: - description: If true, returns document version as part of a hit. + description: When `true`, returns the document version as part of the hit. type: boolean - runtime_mappings: - $ref: '#/components/schemas/_common.mapping:RuntimeFields' seq_no_primary_term: description: |- - If true, returns sequence number and primary term of the last modification + When `true`, returns the sequence number and primary term of the last modification. of each hit. See Optimistic concurrency control. type: boolean pit: @@ -41054,28 +41739,28 @@ components: _index: $ref: '#/components/schemas/_common:IndexName' doc: - description: An artificial document (a document not present in the index) for which you want to retrieve term vectors. + description: An artificial document for which you want to retrieve term vectors. type: object fields: $ref: '#/components/schemas/_common:Fields' field_statistics: - description: If `true`, the response includes the document count, sum of document frequencies, and sum of total term frequencies. + description: When `true`, the response includes the document count, the sum of the document frequencies, and the sum of the term frequencies. type: boolean filter: $ref: '#/components/schemas/_core.termvectors:Filter' offsets: - description: If `true`, the response includes term offsets. + description: When `true`, the response includes the term offsets. type: boolean payloads: - description: If `true`, the response includes term payloads. + description: When `true`, the response includes the term payloads. type: boolean positions: - description: If `true`, the response includes term positions. + description: When `true`, the response includes the term positions. type: boolean routing: $ref: '#/components/schemas/_common:Routing' term_statistics: - description: If true, the response includes term frequency and document frequency. + description: When `true`, the response includes the term frequency and the document frequency. type: boolean version: $ref: '#/components/schemas/_common:VersionNumber' @@ -41113,7 +41798,7 @@ components: _index: $ref: '#/components/schemas/_common:IndexName' rating: - description: The document's relevance with regard to this search request. + description: The document's relevance with regard to the specified search request. type: number required: - _id @@ -41161,26 +41846,26 @@ components: type: object properties: k: - description: Sets the maximum number of documents retrieved per query. This value will act in place of the usual size parameter in the query. + description: Sets the maximum number of documents retrieved per query. This value replaces the `size` parameter in the query. type: number _core.rank_eval:RankEvalMetricDetail: type: object properties: metric_score: - description: The metric_score in the details section shows the contribution of this query to the global quality metric score + description: The `metric_score`, found in the `metric_details` section, shows the contribution of this query to the global quality metric score. type: number unrated_docs: - description: The unrated_docs section contains an _index and _id entry for each document in the search result for this query that didn't have a ratings value. This can be used to ask the user to supply ratings for these documents + description: The `unrated_docs` section contains an `_index` and `_id` entry for each document that didn't have a `ratings` value. This can be used to ask the user to supply ratings for these documents. type: array items: $ref: '#/components/schemas/_core.rank_eval:UnratedDocument' hits: - description: The hits section shows a grouping of the search results with their supplied ratings + description: The `hits` section provides a grouping of the search results with their supplied ratings. type: array items: $ref: '#/components/schemas/_core.rank_eval:RankEvalHitItem' metric_details: - description: The metric_details give additional information about the calculated quality metric (e.g. how many of the retrieved documents were relevant). The content varies for each metric but allows for better interpretation of the results + description: The `metric_details` section provides additional information about the calculated quality metric indicating the number of relevant retrieved documents. The content varies for each metric but allows for better interpretation of the results. type: object additionalProperties: type: object @@ -41197,7 +41882,7 @@ components: - type: object properties: normalize: - description: If set to true, this metric will calculate the Normalized DCG (https://en.wikipedia.org/wiki/Discounted_cumulative_gain#Normalized_DCG). + description: When `true`, calculates the [normalized discounted cumulative gain (nDCG)](https://en.wikipedia.org/wiki/Discounted_cumulative_gain#Normalized_DCG). type: boolean _core.rank_eval:RankEvalMetricExpectedReciprocalRank: allOf: @@ -41205,7 +41890,7 @@ components: - type: object properties: maximum_relevance: - description: The highest relevance grade used in the user-supplied relevance judgments. + description: The highest relevance grade used in user-supplied relevance judgments. type: number required: - maximum_relevance @@ -41219,7 +41904,7 @@ components: - type: object properties: ignore_unlabeled: - description: Controls how unlabeled documents in the search results are counted. If set to true, unlabeled documents are ignored and neither count as relevant or irrelevant. Set to false (the default), they are treated as irrelevant. + description: Controls how unlabeled documents in the search results are counted. When `true`, unlabeled documents are ignored and are not treated as relevant or irrelevant. When `false`, unlabeled documents are treated as irrelevant. type: boolean _core.rank_eval:RankEvalMetricRatingThreshold: allOf: @@ -41227,7 +41912,7 @@ components: - type: object properties: relevant_rating_threshold: - description: Sets the rating threshold above which documents are considered to be "relevant". + description: Sets the rating threshold above which documents are considered to be relevant. type: number _core.rank_eval:RankEvalMetricRecall: allOf: @@ -41250,7 +41935,7 @@ components: request: $ref: '#/components/schemas/_core.rank_eval:RankEvalQuery' ratings: - description: List of document ratings + description: A list of document ratings. type: array items: $ref: '#/components/schemas/_core.rank_eval:DocumentRating' @@ -41289,7 +41974,7 @@ components: type: object properties: batches: - description: The number of scroll responses pulled back by the reindex. + description: The number of scroll responses shown by the reindex. type: number created: description: The number of documents that were successfully created. @@ -41298,10 +41983,10 @@ components: description: The number of documents that were successfully deleted. type: number noops: - description: The number of documents that were ignored because the script used for the reindex returned a `noop` value for `ctx.op`. + description: The number of documents that were ignored because the script used for the reindex operation returned a `noop` value for `ctx.op`. type: number requests_per_second: - description: The number of requests per second effectively executed during the reindex. + description: The number of successful requests per second during the reindex operation. type: number retries: $ref: '#/components/schemas/_common:Retries' @@ -41317,7 +42002,7 @@ components: description: The number of documents that were successfully processed. type: number updated: - description: The number of documents that were successfully updated, for example, a document with same ID already existed prior to reindex updating it. + description: The number of documents that were successfully updated. type: number version_conflicts: description: The number of version conflicts that reindex hits. @@ -41416,7 +42101,7 @@ components: size: description: |- The number of documents to index per batch. - Use when indexing from remote to ensure that the batches fit within the on-heap buffer, which defaults to a maximum size of 100 MB. + Use the `size` setting when indexing from a remote cluster. This ensures that batches fit in the on-heap buffer. The buffer defaults to a maximum size of `100MB`. type: number slice: $ref: '#/components/schemas/_common:SlicedScroll' @@ -41424,15 +42109,13 @@ components: $ref: '#/components/schemas/_common:Sort' _source: $ref: '#/components/schemas/_common:Fields' - runtime_mappings: - $ref: '#/components/schemas/_common.mapping:RuntimeFields' required: - index _core.scripts_painless_execute:PainlessContextSetup: type: object properties: document: - description: Document that's temporarily indexed in-memory and accessible from the script. + description: A document temporarily indexed in-memory and accessible from the Painless script. type: object index: $ref: '#/components/schemas/_common:IndexName' @@ -41455,29 +42138,41 @@ components: type: object properties: build_aggregation: - type: number + type: integer + format: int64 build_aggregation_count: - type: number + type: integer + format: int64 build_leaf_collector: - type: number + type: integer + format: int64 build_leaf_collector_count: - type: number + type: integer + format: int64 collect: - type: number + type: integer + format: int64 collect_count: - type: number + type: integer + format: int64 initialize: - type: number + type: integer + format: int64 initialize_count: - type: number + type: integer + format: int64 post_collection: - type: number + type: integer + format: int64 post_collection_count: - type: number + type: integer + format: int64 reduce: - type: number + type: integer + format: int64 reduce_count: - type: number + type: integer + format: int64 required: - build_aggregation - build_aggregation_count @@ -41515,15 +42210,19 @@ components: type: object properties: segments_with_multi_valued_ords: - type: number + type: integer + format: int32 collection_strategy: type: string segments_with_single_valued_ords: - type: number + type: integer + format: int32 total_buckets: - type: number + type: integer + format: int32 built_buckets: - type: number + type: integer + format: int32 result_strategy: type: string has_filter: @@ -41533,64 +42232,88 @@ components: delegate_debug: $ref: '#/components/schemas/_core.search:AggregationProfileDebug' chars_fetched: - type: number + type: integer + format: int32 extract_count: - type: number + type: integer + format: int32 extract_ns: - type: number + type: integer + format: int32 values_fetched: - type: number + type: integer + format: int32 collect_analyzed_ns: - type: number + type: integer + format: int32 collect_analyzed_count: - type: number + type: integer + format: int32 surviving_buckets: - type: number + type: integer + format: int32 ordinals_collectors_used: - type: number + type: integer + format: int32 ordinals_collectors_overhead_too_high: - type: number + type: integer + format: int32 string_hashing_collectors_used: - type: number + type: integer + format: int32 numeric_collectors_used: - type: number + type: integer + format: int32 empty_collectors_used: - type: number + type: integer + format: int32 deferred_aggregators: type: array items: type: string segments_with_doc_count_field: - type: number + type: integer + format: int32 segments_with_deleted_docs: - type: number + type: integer + format: int32 filters: type: array items: $ref: '#/components/schemas/_core.search:AggregationProfileDelegateDebugFilter' segments_counted: - type: number + type: integer + format: int32 segments_collected: - type: number + type: integer + format: int32 map_reducer: type: string _core.search:AggregationProfileDelegateDebugFilter: type: object properties: results_from_metadata: - type: number + type: integer + format: int32 query: type: string specialized_for: type: string segments_counted_in_constant_time: - type: number + type: integer + format: int32 _core.search:BoundaryScanner: type: string enum: - chars - sentence - word + _core.search:BuiltinHighlighterType: + type: string + enum: + - fvh + - plain + - unified _core.search:Collector: type: object properties: @@ -41644,12 +42367,14 @@ components: $ref: '#/components/schemas/_common:Routing' _score: type: number + format: float _source: type: object text: type: string score: type: number + format: float required: - text _core.search:Context: @@ -41687,17 +42412,23 @@ components: load_source_count: type: number load_stored_fields: - type: number + type: integer + format: int32 load_stored_fields_count: - type: number + type: integer + format: int32 next_reader: - type: number + type: integer + format: int32 next_reader_count: - type: number + type: integer + format: int32 process_count: - type: number + type: integer + format: int32 process: - type: number + type: integer + format: int32 _core.search:FetchProfileDebug: type: object properties: @@ -41706,24 +42437,23 @@ components: items: type: string fast_path: - type: number + type: integer + format: int32 _core.search:FieldCollapse: type: object properties: field: $ref: '#/components/schemas/_common:Field' inner_hits: - description: The number of inner hits and their sort order + description: The number of inner hits and their sort order. oneOf: - $ref: '#/components/schemas/_core.search:InnerHits' - type: array items: $ref: '#/components/schemas/_core.search:InnerHits' max_concurrent_group_searches: - description: The number of concurrent requests allowed to retrieve the inner_hits per group - type: number - collapse: - $ref: '#/components/schemas/_core.search:FieldCollapse' + description: The number of concurrent requests that are allowed to be retrieved by the `inner_hits` parameter per group. + type: integer required: - field _core.search:Highlight: @@ -41749,13 +42479,14 @@ components: type: string boundary_max_scan: description: How far to scan for boundary characters. - type: number + type: integer + format: int32 boundary_scanner: $ref: '#/components/schemas/_core.search:BoundaryScanner' boundary_scanner_locale: description: |- Controls which locale is used to search for sentence and word boundaries. - This parameter takes a form of a language tag, for example: `"en-US"`, `"fr-FR"`, `"ja-JP"`. + This parameter takes the form of a language tag, for example, `"en-US"`, `"fr-FR"`, or `"ja-JP"`. type: string force_source: deprecated: true @@ -41764,30 +42495,35 @@ components: $ref: '#/components/schemas/_core.search:HighlighterFragmenter' fragment_size: description: The size of the highlighted fragment in characters. - type: number + type: integer + format: int32 highlight_filter: type: boolean highlight_query: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' max_fragment_length: - type: number + type: integer + format: int32 max_analyzed_offset: description: |- If set to a non-negative value, highlighting stops at this defined maximum limit. - The rest of the text is not processed, thus not highlighted and no error is returned - The `max_analyzed_offset` query setting does not override the `index.highlight.max_analyzed_offset` setting, which prevails when it's set to lower value than the query setting. - type: number + The rest of the text is not processed or highlighted, and no error is returned. + The `max_analyzed_offset` query setting does not override the `index.highlight.max_analyzed_offset` setting, which takes precedence when it is set to a lower value than the query setting. + type: integer + format: int32 no_match_size: description: The amount of text you want to return from the beginning of the field if there are no matching fragments to highlight. - type: number + type: integer + format: int32 number_of_fragments: description: |- The maximum number of fragments to return. - If the number of fragments is set to `0`, no fragments are returned. - Instead, the entire field contents are highlighted and returned. - This can be handy when you need to highlight short texts such as a title or address, but fragmentation is not required. - If `number_of_fragments` is `0`, `fragment_size` is ignored. - type: number + When the number of fragments is set to `0`, no fragments are returned. + Instead, the entirety of a field's contents are highlighted and returned. + This is useful when you need to highlight short texts, such as a title or address, in which fragmentation is not required. + If `number_of_fragments` is set to `0`, the `fragment_size` is ignored. + type: integer + format: int32 options: type: object additionalProperties: @@ -41797,20 +42533,21 @@ components: phrase_limit: description: |- Controls the number of matching phrases in a document that are considered. - Prevents the `fvh` highlighter from analyzing too many phrases and consuming too much memory. - When using `matched_fields`, `phrase_limit` phrases per matched field are considered. Raising the limit increases query time and consumes more memory. - Only supported by the `fvh` highlighter. - type: number + This prevents the `fvh` highlighter from analyzing too many phrases and consuming too much memory. + When using `matched_fields`, phrase-limited phrases per matched field are considered. Raising the limit increases the query time and consumes more memory. + This setting is only supported by the `fvh` highlighter. + type: integer + format: int32 post_tags: description: |- - Use in conjunction with `pre_tags` to define the HTML tags to use for the highlighted text. + When used in conjunction with `pre_tags`, defines the HTML tags to use for the highlighted text. By default, highlighted text is wrapped in `` and `` tags. type: array items: type: string pre_tags: description: |- - Use in conjunction with `post_tags` to define the HTML tags to use for the highlighted text. + When used in conjunction with `post_tags`, defines the HTML tags to use for the highlighted text. By default, highlighted text is wrapped in `` and `` tags. type: array items: @@ -41841,18 +42578,19 @@ components: enum: - styled _core.search:HighlighterType: - type: string - enum: - - fvh - - plain - - unified + oneOf: + - title: builtin + $ref: '#/components/schemas/_core.search:BuiltinHighlighterType' + - title: custom + type: string _core.search:HighlightField: allOf: - $ref: '#/components/schemas/_core.search:HighlightBase' - type: object properties: fragment_offset: - type: number + type: integer + format: int32 matched_fields: $ref: '#/components/schemas/_common:Fields' analyzer: @@ -41914,7 +42652,8 @@ components: _seq_no: $ref: '#/components/schemas/_common:SequenceNumber' _primary_term: - type: number + type: integer + format: int64 _version: $ref: '#/components/schemas/_common:VersionNumber' sort: @@ -41926,10 +42665,11 @@ components: type: object properties: total: - description: Total hit count information, present only if `track_total_hits` wasn't `false` in the search request. + description: The total number of hits, present only if `track_total_hits` is not set to `false` in the search request. oneOf: - $ref: '#/components/schemas/_core.search:TotalHits' - - type: number + - type: integer + format: int64 hits: type: array items: @@ -41948,10 +42688,12 @@ components: $ref: '#/components/schemas/_common:Name' size: description: The maximum number of hits to return per `inner_hits`. - type: number + type: integer + format: int32 from: - description: Inner hit starting document offset. - type: number + description: The inner hit that initiates document offset. + type: integer + format: int32 collapse: $ref: '#/components/schemas/_core.search:FieldCollapse' docvalue_fields: @@ -41995,7 +42737,8 @@ components: field: $ref: '#/components/schemas/_common:Field' offset: - type: number + type: integer + format: int32 _nested: $ref: '#/components/schemas/_core.search:NestedIdentity' required: @@ -42021,6 +42764,7 @@ components: type: string score: type: number + format: float highlighted: type: string collate_match: @@ -42050,41 +42794,59 @@ components: type: object properties: advance: - type: number + type: integer + format: int64 advance_count: - type: number + type: integer + format: int64 build_scorer: - type: number + type: integer + format: int64 build_scorer_count: - type: number + type: integer + format: int64 create_weight: - type: number + type: integer + format: int64 create_weight_count: - type: number + type: integer + format: int64 match: - type: number + type: integer + format: int64 match_count: - type: number + type: integer + format: int64 shallow_advance: - type: number + type: integer + format: int64 shallow_advance_count: - type: number + type: integer + format: int64 next_doc: - type: number + type: integer + format: int64 next_doc_count: - type: number + type: integer + format: int64 score: - type: number + type: integer + format: int64 score_count: - type: number + type: integer + format: int64 compute_max_score: - type: number + type: integer + format: int64 compute_max_score_count: - type: number + type: integer + format: int64 set_min_competitive_score: - type: number + type: integer + format: int64 set_min_competitive_score_count: - type: number + type: integer + format: int64 required: - advance - advance_count @@ -42130,7 +42892,8 @@ components: query: $ref: '#/components/schemas/_core.search:RescoreQuery' window_size: - type: number + type: integer + format: int32 required: - query _core.search:RescoreQuery: @@ -42139,11 +42902,13 @@ components: rescore_query: $ref: '#/components/schemas/_common.query_dsl:QueryContainer' query_weight: - description: Relative importance of the original query versus the rescore query. + description: The relative importance of the original query as compared to the rescore query. type: number + format: float rescore_query_weight: - description: Relative importance of the rescore query versus the original query. + description: The relative importance of the rescore query as compared to the original query. type: number + format: float score_mode: $ref: '#/components/schemas/_core.search:ScoreMode' required: @@ -42152,7 +42917,8 @@ components: type: object properties: took: - type: number + type: integer + format: int64 timed_out: type: boolean _shards: @@ -42174,8 +42940,10 @@ components: type: object max_score: type: number + format: float num_reduce_phases: - type: number + type: integer + format: int32 profile: $ref: '#/components/schemas/_core.search:Profile' pit_id: @@ -42215,7 +42983,8 @@ components: items: $ref: '#/components/schemas/_core.search:QueryProfile' rewrite_time: - type: number + type: integer + format: int64 required: - collector - query @@ -42242,15 +43011,18 @@ components: _core.search:SourceConfig: description: Defines how to fetch a source. Fetching can be disabled entirely, or the source can be filtered. oneOf: - - type: boolean - - type: array + - title: fetch + type: boolean + - title: includes + type: array items: $ref: '#/components/schemas/_common:Field' - - $ref: '#/components/schemas/_core.search:SourceFilter' + - title: filter + $ref: '#/components/schemas/_core.search:SourceFilter' _core.search:SourceConfigParam: description: |- Defines how to fetch a source. Fetching can be disabled entirely, or the source can be filtered. - Used as a query parameter along with the `_source_includes` and `_source_excludes` parameters. + Use this setting with the `_source_includes` and `_source_excludes` parameters. oneOf: - type: boolean - $ref: '#/components/schemas/_common:Fields' @@ -42270,9 +43042,11 @@ components: type: object properties: length: - type: number + type: integer + format: int32 offset: - type: number + type: integer + format: int32 text: type: string required: @@ -42283,7 +43057,7 @@ components: type: object properties: text: - description: Global suggest text, to avoid repetition when the same text is used in several suggesters + description: The global suggest text, which avoids repetition when the same text is used in several suggesters. type: string _core.search:TermSuggest: allOf: @@ -42305,8 +43079,10 @@ components: type: string score: type: number + format: float freq: type: number + format: double highlighted: type: string collate_match: @@ -42321,7 +43097,8 @@ components: relation: $ref: '#/components/schemas/_core.search:TotalHitsRelation' value: - type: number + type: integer + format: int64 required: - relation - value @@ -42332,13 +43109,14 @@ components: - gte _core.search:TrackHits: description: |- - Number of hits matching the query to count accurately. If true, the exact - number of hits is returned at the cost of some performance. If false, the + The number of hits matching the query. When `true`, the exact + number of hits is returned at the cost of some performance. When `false`, the response does not include the total number of hits matching the query. - Defaults to 10,000 hits. + Default is `10,000` hits. oneOf: - type: boolean - - type: number + - type: integer + format: int32 _core.termvectors:FieldStatistics: type: object properties: @@ -42357,21 +43135,21 @@ components: properties: max_doc_freq: description: |- - Ignore words which occur in more than this many docs. - Defaults to unbounded. + Ignores words that appear in more than the specified number of documents. + Default is `unbounded`. type: number max_num_terms: - description: Maximum number of terms that must be returned per field. + description: The maximum number of terms that should be returned per field. type: number max_term_freq: description: |- Ignore words with more than this frequency in the source doc. - Defaults to unbounded. + Default is `unbounded`. type: number max_word_length: description: |- The maximum word length above which words will be ignored. - Defaults to unbounded. + Default is `unbounded`. type: number min_doc_freq: description: Ignore terms which do not occur in at least this many docs. @@ -42580,7 +43358,8 @@ components: When possible, let OpenSearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers. If set to `0` (default), the query does not terminate early. - type: number + type: integer + format: int32 timeout: description: |- Specifies the period of time to wait for a response from each shard. @@ -42600,8 +43379,6 @@ components: $ref: '#/components/schemas/_common:Fields' pit: $ref: '#/components/schemas/_core.search:PointInTimeReference' - runtime_mappings: - $ref: '#/components/schemas/_common.mapping:RuntimeFields' stats: description: |- Stats groups to associate with the search. @@ -44754,8 +45531,6 @@ components: type: object additionalProperties: $ref: '#/components/schemas/indices._common:AliasDefinition' - lifecycle: - $ref: '#/components/schemas/indices._common:DataStreamLifecycleWithRollover' cluster.allocation_explain:AllocationDecision: type: object properties: @@ -44773,9 +45548,9 @@ components: type: string enum: - ALWAYS - - NO + - 'NO' - THROTTLE - - YES + - 'YES' cluster.allocation_explain:AllocationStore: type: object properties: @@ -44854,12 +45629,12 @@ components: enum: - allocation_delayed - awaiting_info - - no + - 'no' - no_attempt - no_valid_shard_copy - throttled - worse_balance - - yes + - 'yes' cluster.allocation_explain:DiskUsage: type: object properties: @@ -45934,11 +46709,6 @@ components: type: array items: $ref: '#/components/schemas/cluster.stats:FieldTypes' - runtime_field_types: - description: Contains statistics about runtime field data types used in selected nodes. - type: array - items: - $ref: '#/components/schemas/cluster.stats:RuntimeFieldTypes' total_field_count: description: Total number of fields in all non-system indices. type: number @@ -46064,67 +46834,6 @@ components: - total_in_bytes - used_in_bytes - used_percent - cluster.stats:RuntimeFieldTypes: - type: object - properties: - chars_max: - description: Maximum number of characters for a single runtime field script. - type: number - chars_total: - description: Total number of characters for the scripts that define the current runtime field data type. - type: number - count: - description: Number of runtime fields mapped to the field data type in selected nodes. - type: number - doc_max: - description: Maximum number of accesses to doc_values for a single runtime field script - type: number - doc_total: - description: Total number of accesses to doc_values for the scripts that define the current runtime field data type. - type: number - index_count: - description: Number of indices containing a mapping of the runtime field data type in selected nodes. - type: number - lang: - description: Script languages used for the runtime fields scripts. - type: array - items: - type: string - lines_max: - description: Maximum number of lines for a single runtime field script. - type: number - lines_total: - description: Total number of lines for the scripts that define the current runtime field data type. - type: number - name: - $ref: '#/components/schemas/_common:Name' - scriptless_count: - description: Number of runtime fields that don't declare a script. - type: number - shadowed_count: - description: Number of runtime fields that shadow an indexed field. - type: number - source_max: - description: Maximum number of accesses to _source for a single runtime field script. - type: number - source_total: - description: Total number of accesses to _source for the scripts that define the current runtime field data type. - type: number - required: - - chars_max - - chars_total - - count - - doc_max - - doc_total - - index_count - - lang - - lines_max - - lines_total - - name - - scriptless_count - - shadowed_count - - source_max - - source_total cluster.stats:StatsResponseBase: allOf: - $ref: '#/components/schemas/nodes._common:NodesResponseBase' @@ -46800,13 +47509,6 @@ components: If `true`, the alias is hidden. All indices for the alias must have the same `is_hidden` value. type: boolean - indices._common:CacheQueries: - type: object - properties: - enabled: - type: boolean - required: - - enabled indices._common:DataStream: type: object properties: @@ -46835,8 +47537,6 @@ components: type: array items: $ref: '#/components/schemas/indices._common:DataStreamIndex' - lifecycle: - $ref: '#/components/schemas/indices._common:DataStreamLifecycleWithRollover' name: $ref: '#/components/schemas/_common:DataStreamName' replicated: @@ -46875,55 +47575,6 @@ components: required: - index_name - index_uuid - indices._common:DataStreamLifecycle: - type: object - properties: - data_retention: - $ref: '#/components/schemas/_common:Duration' - downsampling: - $ref: '#/components/schemas/indices._common:DataStreamLifecycleDownsampling' - indices._common:DataStreamLifecycleDownsampling: - type: object - properties: - rounds: - description: The list of downsampling rounds to execute as part of this downsampling configuration - type: array - items: - $ref: '#/components/schemas/indices._common:DownsamplingRound' - required: - - rounds - indices._common:DataStreamLifecycleRolloverConditions: - type: object - properties: - min_age: - $ref: '#/components/schemas/_common:Duration' - max_age: - type: string - min_docs: - type: number - max_docs: - type: number - min_size: - $ref: '#/components/schemas/_common:HumanReadableByteCount' - max_size: - $ref: '#/components/schemas/_common:HumanReadableByteCount' - min_primary_shard_size: - $ref: '#/components/schemas/_common:HumanReadableByteCount' - max_primary_shard_size: - $ref: '#/components/schemas/_common:HumanReadableByteCount' - min_primary_shard_docs: - type: number - max_primary_shard_docs: - type: number - indices._common:DataStreamLifecycleWithRollover: - type: object - properties: - data_retention: - $ref: '#/components/schemas/_common:Duration' - downsampling: - $ref: '#/components/schemas/indices._common:DataStreamLifecycleDownsampling' - rollover: - $ref: '#/components/schemas/indices._common:DataStreamLifecycleRolloverConditions' indices._common:DataStreamTimestampField: type: object properties: @@ -46931,32 +47582,17 @@ components: $ref: '#/components/schemas/_common:Field' required: - name - indices._common:DownsampleConfig: - type: object - properties: - fixed_interval: - $ref: '#/components/schemas/_common:DurationLarge' - required: - - fixed_interval - indices._common:DownsamplingRound: - type: object - properties: - after: - $ref: '#/components/schemas/_common:Duration' - config: - $ref: '#/components/schemas/indices._common:DownsampleConfig' - required: - - after - - config indices._common:FielddataFrequencyFilter: type: object properties: max: type: number + format: double min: type: number + format: double min_segment_size: - type: number + type: integer required: - max - min @@ -46967,6 +47603,32 @@ components: - checksum - 'false' - 'true' + indices._common:IndexErrorCause: + type: object + properties: + type: + description: The type of error + type: string + reason: + description: A human-readable explanation of the error, in english + type: string + root_cause: + type: array + items: + $ref: '#/components/schemas/indices._common:IndexErrorCause' + index: + $ref: '#/components/schemas/_common:IndexName' + index_uuid: + $ref: '#/components/schemas/_common:Uuid' + resource.id: + $ref: '#/components/schemas/_common:IndexName' + resource.type: + $ref: '#/components/schemas/_common:ResourceType' + required: + - type + additionalProperties: + title: metadata + description: Additional details about the error. indices._common:IndexingPressure: type: object properties: @@ -46982,14 +47644,17 @@ components: Number of outstanding bytes that may be consumed by indexing requests. When this limit is reached or exceeded, the node will reject new coordinating and primary operations. When replica operations consume 1.5x this limit, the node will reject new replica operations. Defaults to 10% of the heap. - type: number - indices._common:IndexingSlowlogSettings: + oneOf: + - type: string + - type: integer + format: int64 + indices._common:IndexingSlowlog: type: object properties: level: type: string source: - type: number + type: integer reformat: type: boolean threshold: @@ -47021,9 +47686,7 @@ components: type: object properties: threshold_enabled: - oneOf: - - type: boolean - - type: string + $ref: '#/components/schemas/_common:Stringifiedboolean' indices._common:IndexRoutingAllocationInclude: type: object properties: @@ -47109,18 +47772,20 @@ components: type: string soft_deletes: $ref: '#/components/schemas/indices._common:SoftDeletes' + soft_deletes.retention_lease.period: + $ref: '#/components/schemas/_common:Duration' sort: $ref: '#/components/schemas/indices._common:IndexSegmentSort' number_of_shards: oneOf: - - type: number + - type: integer - type: string number_of_replicas: oneOf: - - type: number + - type: integer - type: string number_of_routing_shards: - type: number + type: integer check_on_startup: $ref: '#/components/schemas/indices._common:IndexCheckOnStartup' codec: @@ -47130,43 +47795,59 @@ components: load_fixed_bitset_filters_eagerly: type: boolean hidden: - oneOf: - - type: boolean - - type: string + $ref: '#/components/schemas/_common:Stringifiedboolean' auto_expand_replicas: type: string merge: - $ref: '#/components/schemas/indices._common:Merge' + $ref: '#/components/schemas/indices._common:IndexSettingsMerge' + merge.scheduler.max_thread_count: + $ref: '#/components/schemas/_common:Stringifiedinteger' search: - $ref: '#/components/schemas/indices._common:SettingsSearch' + $ref: '#/components/schemas/indices._common:IndexSettingsSearch' + search.idle.after: + $ref: '#/components/schemas/_common:Duration' refresh_interval: $ref: '#/components/schemas/_common:Duration' max_result_window: - type: number + type: integer max_inner_result_window: - type: number + type: integer max_rescore_window: - type: number + type: integer max_docvalue_fields_search: - type: number + type: integer max_script_fields: - type: number + type: integer max_ngram_diff: - type: number + type: integer max_shingle_diff: - type: number + type: integer blocks: $ref: '#/components/schemas/indices._common:IndexSettingBlocks' + blocks.read_only: + $ref: '#/components/schemas/_common:Stringifiedboolean' + blocks.read_only_allow_delete: + $ref: '#/components/schemas/_common:Stringifiedboolean' + blocks.read: + $ref: '#/components/schemas/_common:Stringifiedboolean' + blocks.write: + $ref: '#/components/schemas/_common:Stringifiedboolean' + blocks.metadata: + $ref: '#/components/schemas/_common:Stringifiedboolean' max_refresh_listeners: - type: number + type: integer analyze: - $ref: '#/components/schemas/indices._common:SettingsAnalyze' + $ref: '#/components/schemas/indices._common:IndexSettingsAnalyze' + analyze.max_token_count: + $ref: '#/components/schemas/_common:Stringifiedinteger' highlight: - $ref: '#/components/schemas/indices._common:SettingsHighlight' + $ref: '#/components/schemas/indices._common:IndexSettingsHighlight' + highlight.max_analyzed_offset: + type: integer max_terms_count: - type: number + type: integer max_regex_length: - type: number + type: integer routing: $ref: '#/components/schemas/indices._common:IndexRouting' gc_deletes: @@ -47177,6 +47858,8 @@ components: $ref: '#/components/schemas/_common:PipelineName' lifecycle: $ref: '#/components/schemas/indices._common:IndexSettingsLifecycle' + lifecycle.name: + $ref: '#/components/schemas/_common:Name' provided_name: $ref: '#/components/schemas/_common:Name' creation_date: @@ -47188,25 +47871,29 @@ components: version: $ref: '#/components/schemas/indices._common:IndexVersioning' verified_before_close: - oneOf: - - type: boolean - - type: string + $ref: '#/components/schemas/_common:Stringifiedboolean' format: oneOf: - type: string - type: number max_slices_per_scroll: - type: number + type: integer translog: $ref: '#/components/schemas/indices._common:Translog' + translog.durability: + $ref: '#/components/schemas/indices._common:TranslogDurability' + translog.flush_threshold_size: + $ref: '#/components/schemas/_common:HumanReadableByteCount' query_string: - $ref: '#/components/schemas/indices._common:SettingsQueryString' + $ref: '#/components/schemas/indices._common:IndexSettingsQueryString' + query_string.lenient: + $ref: '#/components/schemas/_common:Stringifiedboolean' priority: oneOf: - type: number - type: string top_metrics_max_size: - type: number + type: integer analysis: $ref: '#/components/schemas/indices._common:IndexSettingsAnalysis' settings: @@ -47214,18 +47901,23 @@ components: time_series: $ref: '#/components/schemas/indices._common:IndexSettingsTimeSeries' queries: - $ref: '#/components/schemas/indices._common:Queries' + $ref: '#/components/schemas/indices._common:IndexSettingsQueries' similarity: - $ref: '#/components/schemas/indices._common:SettingsSimilarity' + $ref: '#/components/schemas/indices._common:IndexSettingsSimilarity' mapping: - $ref: '#/components/schemas/indices._common:MappingLimitSettings' - indexing.slowlog: - $ref: '#/components/schemas/indices._common:IndexingSlowlogSettings' + $ref: '#/components/schemas/indices._common:IndexSettingsMapping' + indexing: + $ref: '#/components/schemas/indices._common:IndexSettingsIndexing' indexing_pressure: $ref: '#/components/schemas/indices._common:IndexingPressure' store: - $ref: '#/components/schemas/indices._common:Storage' - additionalProperties: {} + $ref: '#/components/schemas/indices._common:IndexSettingsStore' + knn: + type: boolean + knn.algo_param.ef_search: + type: integer + additionalProperties: + title: custom_settings indices._common:IndexSettingsAnalysis: type: object properties: @@ -47249,6 +47941,21 @@ components: type: object additionalProperties: $ref: '#/components/schemas/_common.analysis:Tokenizer' + indices._common:IndexSettingsAnalyze: + type: object + properties: + max_token_count: + $ref: '#/components/schemas/_common:Stringifiedinteger' + indices._common:IndexSettingsHighlight: + type: object + properties: + max_analyzed_offset: + type: integer + indices._common:IndexSettingsIndexing: + type: object + properties: + slowlog: + $ref: '#/components/schemas/indices._common:IndexingSlowlog' indices._common:IndexSettingsLifecycle: type: object properties: @@ -47261,7 +47968,7 @@ components: If specified, this is the timestamp used to calculate the index age for its phase transitions. Use this setting if you create a new index that contains old data and want to use the original creation date to calculate the index age. Specified as a Unix epoch value in milliseconds. - type: number + $ref: '#/components/schemas/_common:StringifiedEpochTimeUnitMillis' parse_origination_date: description: |- Set to true to parse the origination date from the index name. This origination date is used to calculate the index age @@ -47284,140 +47991,44 @@ components: properties: wait_time_threshold: $ref: '#/components/schemas/_common:Duration' - indices._common:IndexSettingsTimeSeries: - type: object - properties: - end_time: - $ref: '#/components/schemas/_common:DateTime' - start_time: - $ref: '#/components/schemas/_common:DateTime' - indices._common:IndexState: - type: object - properties: - aliases: - type: object - additionalProperties: - $ref: '#/components/schemas/indices._common:Alias' - mappings: - $ref: '#/components/schemas/_common.mapping:TypeMapping' - settings: - $ref: '#/components/schemas/indices._common:IndexSettings' - defaults: - $ref: '#/components/schemas/indices._common:IndexSettings' - data_stream: - $ref: '#/components/schemas/_common:DataStreamName' - lifecycle: - $ref: '#/components/schemas/indices._common:DataStreamLifecycle' - indices._common:IndexTemplate: - type: object - properties: - index_patterns: - $ref: '#/components/schemas/_common:Names' - composed_of: - description: |- - An ordered list of component template names. - Component templates are merged in the order specified, meaning that the last component template specified has the highest precedence. - type: array - items: - $ref: '#/components/schemas/_common:Name' - template: - $ref: '#/components/schemas/indices._common:IndexTemplateSummary' - version: - $ref: '#/components/schemas/_common:VersionNumber' - priority: - description: |- - Priority to determine index template precedence when a new data stream or index is created. - The index template with the highest priority is chosen. - If no priority is specified the template is treated as though it is of priority 0 (lowest priority). - This number is not automatically generated by OpenSearch. - type: number - _meta: - $ref: '#/components/schemas/_common:Metadata' - allow_auto_create: - type: boolean - data_stream: - $ref: '#/components/schemas/indices._common:IndexTemplateDataStreamConfiguration' - required: - - index_patterns - description: New index template definition to be simulated, if no index template name is specified. - indices._common:IndexTemplateDataStreamConfiguration: - type: object - properties: - hidden: - description: If true, the data stream is hidden. - type: boolean - allow_custom_routing: - description: If true, the data stream supports custom routing. - type: boolean - timestamp_field: - $ref: '#/components/schemas/indices._common:DataStreamTimestampField' - indices._common:IndexTemplateSummary: - type: object - properties: - aliases: - description: |- - Aliases to add. - If the index template includes a `data_stream` object, these are data stream aliases. - Otherwise, these are index aliases. - Data stream aliases ignore the `index_routing`, `routing`, and `search_routing` options. - type: object - additionalProperties: - $ref: '#/components/schemas/indices._common:Alias' - mappings: - $ref: '#/components/schemas/_common.mapping:TypeMapping' - settings: - $ref: '#/components/schemas/indices._common:IndexSettings' - lifecycle: - $ref: '#/components/schemas/indices._common:DataStreamLifecycleWithRollover' - indices._common:IndexVersioning: - type: object - properties: - created: - $ref: '#/components/schemas/_common:VersionString' - created_string: - type: string - indices._common:ManagedBy: - type: string - enum: - - Data stream lifecycle - - Index Lifecycle Management - - Unmanaged - indices._common:MappingLimitSettings: + indices._common:IndexSettingsMapping: type: object properties: coerce: type: boolean total_fields: - $ref: '#/components/schemas/indices._common:MappingLimitSettingsTotalFields' + $ref: '#/components/schemas/indices._common:IndexSettingsMappingLimitTotalFields' depth: - $ref: '#/components/schemas/indices._common:MappingLimitSettingsDepth' + $ref: '#/components/schemas/indices._common:IndexSettingsMappingLimitDepth' nested_fields: - $ref: '#/components/schemas/indices._common:MappingLimitSettingsNestedFields' + $ref: '#/components/schemas/indices._common:IndexSettingsMappingLimitNestedFields' nested_objects: - $ref: '#/components/schemas/indices._common:MappingLimitSettingsNestedObjects' + $ref: '#/components/schemas/indices._common:IndexSettingsMappingLimitNestedObjects' field_name_length: - $ref: '#/components/schemas/indices._common:MappingLimitSettingsFieldNameLength' + $ref: '#/components/schemas/indices._common:IndexSettingsMappingLimitFieldNameLength' dimension_fields: - $ref: '#/components/schemas/indices._common:MappingLimitSettingsDimensionFields' + $ref: '#/components/schemas/indices._common:IndexSettingsMappingLimitDimensionFields' ignore_malformed: type: boolean - indices._common:MappingLimitSettingsDepth: + indices._common:IndexSettingsMappingLimitDepth: type: object properties: limit: description: |- The maximum depth for a field, which is measured as the number of inner objects. For instance, if all fields are defined at the root object level, then the depth is 1. If there is one object mapping, then the depth is 2, etc. - type: number - indices._common:MappingLimitSettingsDimensionFields: + type: integer + format: int64 + indices._common:IndexSettingsMappingLimitDimensionFields: type: object properties: limit: description: |- [preview] This functionality is in technical preview and may be changed or removed in a future release. OpenSearch will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. - type: number - indices._common:MappingLimitSettingsFieldNameLength: + type: integer + format: int64 + indices._common:IndexSettingsMappingLimitFieldNameLength: type: object properties: limit: @@ -47425,8 +48036,9 @@ components: Setting for the maximum length of a field name. This setting isn't really something that addresses mappings explosion but might still be useful if you want to limit the field length. It usually shouldn't be necessary to set this setting. The default is okay unless a user starts to add a huge number of fields with really long names. Default is `Long.MAX_VALUE` (no limit). - type: number - indices._common:MappingLimitSettingsNestedFields: + type: integer + format: int64 + indices._common:IndexSettingsMappingLimitNestedFields: type: object properties: limit: @@ -47434,16 +48046,18 @@ components: The maximum number of distinct nested mappings in an index. The nested type should only be used in special cases, when arrays of objects need to be queried independently of each other. To safeguard against poorly designed mappings, this setting limits the number of unique nested types per index. - type: number - indices._common:MappingLimitSettingsNestedObjects: + type: integer + format: int64 + indices._common:IndexSettingsMappingLimitNestedObjects: type: object properties: limit: description: |- The maximum number of nested JSON objects that a single document can contain across all nested types. This limit helps to prevent out of memory errors when a document contains too many nested objects. - type: number - indices._common:MappingLimitSettingsTotalFields: + type: integer + format: int64 + indices._common:IndexSettingsMappingLimitTotalFields: type: object properties: limit: @@ -47451,113 +48065,72 @@ components: The maximum number of fields in an index. Field and object mappings, as well as field aliases count towards this limit. The limit is in place to prevent mappings and searches from becoming too large. Higher values can lead to performance degradations and memory issues, especially in clusters with a high load or few resources. - type: number - indices._common:Merge: + type: integer + format: int64 + indices._common:IndexSettingsMerge: type: object properties: scheduler: - $ref: '#/components/schemas/indices._common:MergeScheduler' - indices._common:MergeScheduler: + $ref: '#/components/schemas/indices._common:IndexSettingsMergeScheduler' + indices._common:IndexSettingsMergeScheduler: type: object properties: max_thread_count: $ref: '#/components/schemas/_common:Stringifiedinteger' max_merge_count: $ref: '#/components/schemas/_common:Stringifiedinteger' - indices._common:NumericFielddata: - type: object - properties: - format: - $ref: '#/components/schemas/indices._common:NumericFielddataFormat' - required: - - format - indices._common:NumericFielddataFormat: - type: string - enum: - - array - - disabled - indices._common:Queries: + indices._common:IndexSettingsQueries: type: object properties: cache: - $ref: '#/components/schemas/indices._common:CacheQueries' - indices._common:RetentionLease: + $ref: '#/components/schemas/indices._common:IndexSettingsQueriesCache' + indices._common:IndexSettingsQueriesCache: type: object properties: - period: - $ref: '#/components/schemas/_common:Duration' + enabled: + type: boolean required: - - period - indices._common:SearchIdle: - type: object - properties: - after: - $ref: '#/components/schemas/_common:Duration' - indices._common:SegmentSortMissing: - type: string - enum: - - _first - - _last - indices._common:SegmentSortMode: - type: string - enum: - - max - - min - indices._common:SegmentSortOrder: - type: string - enum: - - asc - - desc - indices._common:SettingsAnalyze: - type: object - properties: - max_token_count: - $ref: '#/components/schemas/_common:Stringifiedinteger' - indices._common:SettingsHighlight: - type: object - properties: - max_analyzed_offset: - type: number - indices._common:SettingsQueryString: + - enabled + indices._common:IndexSettingsQueryString: type: object properties: lenient: $ref: '#/components/schemas/_common:Stringifiedboolean' - required: - - lenient - indices._common:SettingsSearch: + indices._common:IndexSettingsSearch: type: object properties: idle: $ref: '#/components/schemas/indices._common:SearchIdle' slowlog: - $ref: '#/components/schemas/indices._common:SlowlogSettings' - indices._common:SettingsSimilarity: + $ref: '#/components/schemas/indices._common:SearchSlowlog' + indices._common:IndexSettingsSimilarity: type: object properties: bm25: - $ref: '#/components/schemas/indices._common:SettingsSimilarityBm25' + $ref: '#/components/schemas/indices._common:IndexSettingsSimilarityBm25' dfi: - $ref: '#/components/schemas/indices._common:SettingsSimilarityDfi' + $ref: '#/components/schemas/indices._common:IndexSettingsSimilarityDfi' dfr: - $ref: '#/components/schemas/indices._common:SettingsSimilarityDfr' + $ref: '#/components/schemas/indices._common:IndexSettingsSimilarityDfr' ib: - $ref: '#/components/schemas/indices._common:SettingsSimilarityIb' + $ref: '#/components/schemas/indices._common:IndexSettingsSimilarityIb' lmd: - $ref: '#/components/schemas/indices._common:SettingsSimilarityLmd' + $ref: '#/components/schemas/indices._common:IndexSettingsSimilarityLmd' lmj: - $ref: '#/components/schemas/indices._common:SettingsSimilarityLmj' + $ref: '#/components/schemas/indices._common:IndexSettingsSimilarityLmj' scripted_tfidf: - $ref: '#/components/schemas/indices._common:SettingsSimilarityScriptedTfidf' - indices._common:SettingsSimilarityBm25: + $ref: '#/components/schemas/indices._common:IndexSettingsSimilarityScriptedTfidf' + indices._common:IndexSettingsSimilarityBm25: type: object properties: b: type: number + format: float discount_overlaps: type: boolean k1: type: number + format: float type: type: string enum: @@ -47567,7 +48140,7 @@ components: - discount_overlaps - k1 - type - indices._common:SettingsSimilarityDfi: + indices._common:IndexSettingsSimilarityDfi: type: object properties: independence_measure: @@ -47579,7 +48152,7 @@ components: required: - independence_measure - type - indices._common:SettingsSimilarityDfr: + indices._common:IndexSettingsSimilarityDfr: type: object properties: after_effect: @@ -47587,7 +48160,7 @@ components: basic_model: $ref: '#/components/schemas/_common:DFRBasicModel' normalization: - $ref: '#/components/schemas/_common:Normalization' + $ref: '#/components/schemas/_common:TermFrequencyNormalization' type: type: string enum: @@ -47597,7 +48170,7 @@ components: - basic_model - normalization - type - indices._common:SettingsSimilarityIb: + indices._common:IndexSettingsSimilarityIb: type: object properties: distribution: @@ -47605,7 +48178,7 @@ components: lambda: $ref: '#/components/schemas/_common:IBLambda' normalization: - $ref: '#/components/schemas/_common:Normalization' + $ref: '#/components/schemas/_common:TermFrequencyNormalization' type: type: string enum: @@ -47615,11 +48188,12 @@ components: - lambda - normalization - type - indices._common:SettingsSimilarityLmd: + indices._common:IndexSettingsSimilarityLmd: type: object properties: mu: type: number + format: float type: type: string enum: @@ -47627,11 +48201,12 @@ components: required: - mu - type - indices._common:SettingsSimilarityLmj: + indices._common:IndexSettingsSimilarityLmj: type: object properties: lambda: type: number + format: float type: type: string enum: @@ -47639,7 +48214,7 @@ components: required: - lambda - type - indices._common:SettingsSimilarityScriptedTfidf: + indices._common:IndexSettingsSimilarityScriptedTfidf: type: object properties: script: @@ -47651,17 +48226,169 @@ components: required: - script - type - indices._common:SlowlogSettings: + indices._common:IndexSettingsStore: + type: object + properties: + type: + $ref: '#/components/schemas/indices._common:StorageType' + allow_mmap: + description: |- + You can restrict the use of the mmapfs and the related hybridfs store type via the setting node.store.allow_mmap. + This is a boolean setting indicating whether or not memory-mapping is allowed. The default is to allow it. This + setting is useful, for example, if you are in an environment where you can not control the ability to create a lot + of memory maps so you need disable the ability to use memory-mapping. + type: boolean + required: + - type + indices._common:IndexSettingsTimeSeries: + type: object + properties: + end_time: + $ref: '#/components/schemas/_common:DateTime' + start_time: + $ref: '#/components/schemas/_common:DateTime' + indices._common:IndexState: + type: object + properties: + aliases: + type: object + additionalProperties: + $ref: '#/components/schemas/indices._common:Alias' + mappings: + $ref: '#/components/schemas/_common.mapping:TypeMapping' + settings: + $ref: '#/components/schemas/indices._common:IndexSettings' + defaults: + $ref: '#/components/schemas/indices._common:IndexSettings' + data_stream: + $ref: '#/components/schemas/_common:DataStreamName' + indices._common:IndexTemplate: + type: object + properties: + index_patterns: + $ref: '#/components/schemas/_common:Names' + composed_of: + description: |- + An ordered list of component template names. + Component templates are merged in the order specified, meaning that the last component template specified has the highest precedence. + type: array + items: + $ref: '#/components/schemas/_common:Name' + template: + $ref: '#/components/schemas/indices._common:IndexTemplateSummary' + version: + $ref: '#/components/schemas/_common:VersionNumber' + priority: + description: |- + Priority to determine index template precedence when a new data stream or index is created. + The index template with the highest priority is chosen. + If no priority is specified the template is treated as though it is of priority 0 (lowest priority). + This number is not automatically generated by OpenSearch. + type: number + _meta: + $ref: '#/components/schemas/_common:Metadata' + allow_auto_create: + type: boolean + data_stream: + $ref: '#/components/schemas/indices._common:IndexTemplateDataStreamConfiguration' + required: + - index_patterns + description: New index template definition to be simulated, if no index template name is specified. + indices._common:IndexTemplateDataStreamConfiguration: + type: object + properties: + hidden: + description: If true, the data stream is hidden. + type: boolean + allow_custom_routing: + description: If true, the data stream supports custom routing. + type: boolean + timestamp_field: + $ref: '#/components/schemas/indices._common:DataStreamTimestampField' + indices._common:IndexTemplateSummary: + type: object + properties: + aliases: + description: |- + Aliases to add. + If the index template includes a `data_stream` object, these are data stream aliases. + Otherwise, these are index aliases. + Data stream aliases ignore the `index_routing`, `routing`, and `search_routing` options. + type: object + additionalProperties: + $ref: '#/components/schemas/indices._common:Alias' + mappings: + $ref: '#/components/schemas/_common.mapping:TypeMapping' + settings: + $ref: '#/components/schemas/indices._common:IndexSettings' + indices._common:IndexVersioning: + type: object + properties: + created: + $ref: '#/components/schemas/_common:VersionString' + created_string: + type: string + indices._common:ManagedBy: + type: string + enum: + - Data stream lifecycle + - Index Lifecycle Management + - Unmanaged + indices._common:NumericFielddata: + type: object + properties: + format: + $ref: '#/components/schemas/indices._common:NumericFielddataFormat' + required: + - format + indices._common:NumericFielddataFormat: + type: string + enum: + - array + - disabled + indices._common:RetentionLease: + type: object + properties: + period: + $ref: '#/components/schemas/_common:Duration' + required: + - period + indices._common:SearchIdle: + type: object + properties: + after: + $ref: '#/components/schemas/_common:Duration' + indices._common:SearchSlowlog: type: object properties: level: type: string - source: - type: number reformat: type: boolean threshold: - $ref: '#/components/schemas/indices._common:SlowlogThresholds' + $ref: '#/components/schemas/indices._common:SearchSlowlogThresholds' + indices._common:SearchSlowlogThresholds: + type: object + properties: + query: + $ref: '#/components/schemas/indices._common:SlowlogThresholdLevels' + fetch: + $ref: '#/components/schemas/indices._common:SlowlogThresholdLevels' + indices._common:SegmentSortMissing: + type: string + enum: + - _first + - _last + indices._common:SegmentSortMode: + type: string + enum: + - max + - min + indices._common:SegmentSortOrder: + type: string + enum: + - asc + - desc indices._common:SlowlogThresholdLevels: type: object properties: @@ -47673,13 +48400,6 @@ components: $ref: '#/components/schemas/_common:Duration' trace: $ref: '#/components/schemas/_common:Duration' - indices._common:SlowlogThresholds: - type: object - properties: - query: - $ref: '#/components/schemas/indices._common:SlowlogThresholdLevels' - fetch: - $ref: '#/components/schemas/indices._common:SlowlogThresholdLevels' indices._common:SoftDeletes: type: object properties: @@ -47688,20 +48408,6 @@ components: type: boolean retention_lease: $ref: '#/components/schemas/indices._common:RetentionLease' - indices._common:Storage: - type: object - properties: - type: - $ref: '#/components/schemas/indices._common:StorageType' - allow_mmap: - description: |- - You can restrict the use of the mmapfs and the related hybridfs store type via the setting node.store.allow_mmap. - This is a boolean setting indicating whether or not memory-mapping is allowed. The default is to allow it. This - setting is useful, for example, if you are in an environment where you can not control the ability to create a lot - of memory maps so you need disable the ability to use memory-mapping. - type: boolean - required: - - type indices._common:StorageType: type: string enum: @@ -47750,6 +48456,8 @@ components: indices._common:TranslogDurability: type: string enum: + - ASYNC + - REQUEST - async - request indices._common:TranslogRetention: @@ -47981,8 +48689,6 @@ components: $ref: '#/components/schemas/_common.mapping:TypeMapping' settings: $ref: '#/components/schemas/indices._common:IndexSettings' - lifecycle: - $ref: '#/components/schemas/indices._common:DataStreamLifecycle' indices.recovery:FileDetails: type: object properties: @@ -48096,6 +48802,18 @@ components: $ref: '#/components/schemas/_common:Uuid' index: $ref: '#/components/schemas/_common:IndexName' + isSearchableSnapshot: + type: boolean + remoteStoreIndexShallowCopy: + type: boolean + sourceRemoteStoreRepository: + type: + - 'null' + - string + sourceRemoteTranslogRepository: + type: + - 'null' + - string indices.recovery:RecoveryStartStatus: type: object properties: @@ -49695,6 +50413,225 @@ components: type: string status: $ref: '#/components/schemas/_common:ActionStatusOptions' + insights._common:Measurement: + type: object + properties: + number: + type: integer + count: + type: integer + aggregationType: + type: string + insights._common:Measurements: + type: object + properties: + latency: + type: object + $ref: '#/components/schemas/insights._common:Measurement' + cpu: + type: object + $ref: '#/components/schemas/insights._common:Measurement' + memory: + type: object + $ref: '#/components/schemas/insights._common:Measurement' + insights._common:Source: + type: object + properties: + aggregations: + description: Defines the aggregations that are run as part of the search request. + type: object + collapse: + $ref: '#/components/schemas/_core.search:FieldCollapse' + explain: + description: If true, returns detailed information about score computation as part of a hit. + type: boolean + ext: + description: Configuration of search extensions defined by OpenSearch plugins. + type: object + additionalProperties: + type: object + from: + description: |- + Starting document offset. + Needs to be non-negative. + By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters. + To page through more hits, use the `search_after` parameter. + type: number + highlight: + $ref: '#/components/schemas/_core.search:Highlight' + track_total_hits: + $ref: '#/components/schemas/_core.search:TrackHits' + indices_boost: + description: Boosts the _score of documents from specified indices. + type: array + items: + type: object + additionalProperties: + type: number + docvalue_fields: + description: |- + Array of wildcard (`*`) patterns. + The request returns doc values for field names matching these patterns in the `hits.fields` property of the response. + type: array + items: + $ref: '#/components/schemas/_common.query_dsl:FieldAndFormat' + min_score: + description: |- + Minimum `_score` for matching documents. + Documents with a lower `_score` are not included in the search results. + type: number + post_filter: + $ref: '#/components/schemas/_common.query_dsl:QueryContainer' + profile: + description: |- + Set to `true` to return detailed timing information about the execution of individual components in a search request. + NOTE: This is a debugging tool and adds significant overhead to search execution. + type: boolean + query: + $ref: '#/components/schemas/_common.query_dsl:QueryContainer' + script_fields: + description: Retrieve a script evaluation (based on different fields) for each hit. + type: object + additionalProperties: + $ref: '#/components/schemas/_common:ScriptField' + search_after: + $ref: '#/components/schemas/_common:SortResults' + size: + description: |- + The number of hits to return. + By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters. + To page through more hits, use the `search_after` parameter. + type: number + slice: + $ref: '#/components/schemas/_common:SlicedScroll' + sort: + $ref: '#/components/schemas/_common:Sort' + _source: + $ref: '#/components/schemas/_core.search:SourceConfig' + fields: + description: |- + Array of wildcard (`*`) patterns. + The request returns values for field names matching these patterns in the `hits.fields` property of the response. + type: array + items: + $ref: '#/components/schemas/_common.query_dsl:FieldAndFormat' + suggest: + $ref: '#/components/schemas/_core.search:Suggester' + terminate_after: + description: |- + Maximum number of documents to collect for each shard. + If a query reaches this limit, OpenSearch terminates the query early. + OpenSearch collects documents before sorting. + Use with caution. + OpenSearch applies this parameter to each shard handling the request. + When possible, let OpenSearch perform early termination automatically. + Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers. + If set to `0` (default), the query does not terminate early. + type: integer + format: int32 + timeout: + description: |- + Specifies the period of time to wait for a response from each shard. + If no response is received before the timeout expires, the request fails and returns an error. + Defaults to no timeout. + type: string + track_scores: + description: If true, calculate and return document scores, even if the scores are not used for sorting. + type: boolean + version: + description: If true, returns document version as part of a hit. + type: boolean + seq_no_primary_term: + description: If `true`, returns sequence number and primary term of the last modification of each hit. + type: boolean + stored_fields: + $ref: '#/components/schemas/_common:Fields' + pit: + $ref: '#/components/schemas/_core.search:PointInTimeReference' + stats: + description: |- + Stats groups to associate with the search. + Each group maintains a statistics aggregation for its associated searches. + You can retrieve these stats using the indices stats API. + type: array + items: + type: string + insights._common:TaskResourceUsage: + type: object + properties: + cpu_time_in_nanos: + type: integer + description: The CPU time used in nanoseconds. + memory_in_bytes: + type: integer + description: The memory usage in bytes. + insights._common:TaskResourceUsages: + type: object + properties: + action: + type: string + description: The action type of the task. + taskId: + type: integer + description: The task ID. + parentTaskId: + type: integer + description: The parent task ID. + nodeId: + type: string + description: The node ID where the task was executed. + taskResourceUsage: + type: object + $ref: '#/components/schemas/insights._common:TaskResourceUsage' + insights._common:TopQueriesResponse: + type: object + properties: + top_queries: + type: array + items: + type: object + $ref: '#/components/schemas/insights._common:TopQuery' + required: + - top_queries + insights._common:TopQuery: + type: object + properties: + timestamp: + type: integer + description: The timestamp of the query execution. + total_shards: + type: integer + description: The total number of shards involved in the query. + task_resource_usages: + type: array + items: + type: object + $ref: '#/components/schemas/insights._common:TaskResourceUsages' + query_hashcode: + type: string + description: The hash code of the query. + labels: + type: object + description: Additional labels for the query. + search_type: + type: string + description: The search query type (e.g., query_then_fetch). + source: + type: object + $ref: '#/components/schemas/insights._common:Source' + node_id: + type: string + description: The node ID associated with the query. + indices: + type: array + items: + type: string + description: The indices involved in the query. + phase_latency_map: + type: object + measurements: + type: object + $ref: '#/components/schemas/insights._common:Measurements' ism._common:Action: type: object description: An action to perform. @@ -51236,6 +52173,12 @@ components: $ref: '#/components/schemas/_common:Duration' cumulative_execution_time_millis: $ref: '#/components/schemas/_common:DurationValueUnitMillis' + nodes._common:RemoteStoreStats: + type: object + properties: + last_successful_fetch_of_pinned_timestamps: + description: Timestamp for the last successful fetch of pinned timestamps. + $ref: '#/components/schemas/_common:StringifiedEpochTimeUnitSeconds' nodes._common:SampleType: type: string description: The type to sample. @@ -51596,6 +52539,8 @@ components: $ref: '#/components/schemas/nodes._common:ShardSearchPipelineStats' segment_replication_backpressure: $ref: '#/components/schemas/nodes._common:ShardSegmentReplicationBackpressureStats' + remote_store: + $ref: '#/components/schemas/nodes._common:RemoteStoreStats' repositories: $ref: '#/components/schemas/nodes._common:ShardRepositoriesStats' admission_control: @@ -52730,23 +53675,14 @@ components: notifications._common:RestStatus: type: string enum: - - accepted - - continue - - created - - found - - moved_permanently - - multi_status - - multiple_choices - - no_content - - non_authoritative_information - - not_modified - - ok - - partial_content - - reset_content - - see_other - - switching_protocols - - temporary_redirect - - use_proxy + - ACCEPTED + - CREATED + - MULTI_STATUS + - NON_AUTHORITATIVE_INFORMATION + - NO_CONTENT + - OK + - PARTIAL_CONTENT + - RESET_CONTENT notifications._common:SesAccount: type: object properties: @@ -53034,7 +53970,7 @@ components: type: string x: type: integer - y: + 'y': type: integer w: type: integer @@ -53046,7 +53982,7 @@ components: - savedVisualizationId - w - x - - y + - 'y' query._common:Credentials: type: object properties: @@ -54578,31 +55514,6 @@ components: required: - file_count - size_in_bytes - snapshot._common:IndexDetails: - type: object - properties: - shard_count: - type: number - size: - $ref: '#/components/schemas/_common:HumanReadableByteCount' - size_in_bytes: - $ref: '#/components/schemas/_common:ByteCount' - max_segments_per_shard: - type: number - required: - - max_segments_per_shard - - shard_count - - size_in_bytes - snapshot._common:InfoFeatureState: - type: object - properties: - feature_name: - type: string - indices: - $ref: '#/components/schemas/_common:Indices' - required: - - feature_name - - indices snapshot._common:Repository: type: object properties: @@ -54734,16 +55645,14 @@ components: type: array items: $ref: '#/components/schemas/_common:IndexName' - index_details: - type: object - additionalProperties: - $ref: '#/components/schemas/snapshot._common:IndexDetails' metadata: $ref: '#/components/schemas/_common:Metadata' + pinned_timestamp: + $ref: '#/components/schemas/_common:EpochTimeUnitMillis' reason: type: string - repository: - $ref: '#/components/schemas/_common:Name' + remote_store_index_shallow_copy: + type: boolean snapshot: $ref: '#/components/schemas/_common:Name' shards: @@ -54760,10 +55669,6 @@ components: $ref: '#/components/schemas/_common:VersionString' version_id: $ref: '#/components/schemas/_common:VersionNumber' - feature_states: - type: array - items: - $ref: '#/components/schemas/snapshot._common:InfoFeatureState' required: - data_streams - snapshot @@ -54849,26 +55754,15 @@ components: properties: deleted_blobs: description: Number of binary large objects (blobs) removed during cleanup. - type: number + type: integer + format: int64 deleted_bytes: description: Number of bytes freed by cleanup operations. - type: number + type: integer + format: int64 required: - deleted_blobs - deleted_bytes - snapshot.get:SnapshotResponseItem: - type: object - properties: - repository: - $ref: '#/components/schemas/_common:Name' - snapshots: - type: array - items: - $ref: '#/components/schemas/snapshot._common:SnapshotInfo' - error: - $ref: '#/components/schemas/_common:ErrorCause' - required: - - repository snapshot.restore:SnapshotRestore: type: object properties: @@ -55374,3 +56268,104 @@ components: type: array items: $ref: '#/components/schemas/transforms._common:TransformEntity' + wlm._common:QueryGroupCreate: + type: object + properties: + name: + type: string + resiliency_mode: + type: string + enum: + - enforced + - monitor + - soft + resource_limits: + anyOf: + - type: object + properties: + memory: + type: number + format: double + cpu: + type: number + format: double + required: + - memory + - type: object + properties: + memory: + type: number + format: double + cpu: + type: number + format: double + required: + - cpu + required: + - name + - resiliency_mode + - resource_limits + wlm._common:QueryGroupResponse: + type: object + properties: + _id: + type: string + name: + type: string + resiliency_mode: + type: string + enum: + - enforced + - monitor + - soft + updated_at: + type: integer + format: int64 + resource_limits: + anyOf: + - type: object + properties: + memory: + type: number + format: double + cpu: + type: number + format: double + required: + - memory + - type: object + properties: + memory: + type: number + format: double + cpu: + type: number + format: double + required: + - cpu + required: + - _id + - name + - resiliency_mode + - resource_limits + - updated_at + wlm._common:QueryGroupUpdate: + type: object + properties: + resiliency_mode: + type: string + enum: + - enforced + - monitor + - soft + resource_limits: + $ref: '#/components/schemas/wlm._common:ResourceLimitsSchema' + wlm._common:ResourceLimitsSchema: + type: object + properties: + memory: + type: number + format: double + cpu: + type: number + format: double diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ArrayShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ArrayShape.java index d04f66f6f7..9e53bbb660 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ArrayShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ArrayShape.java @@ -10,12 +10,20 @@ import java.util.Collection; import java.util.List; +import org.opensearch.client.codegen.model.overrides.ShouldGenerate; public class ArrayShape extends ObjectShape { private final Field valueBodyField; - public ArrayShape(Namespace parent, String className, Type arrayType, String typedefName, String description) { - super(parent, className, typedefName, description); + public ArrayShape( + Namespace parent, + String className, + Type arrayType, + String typedefName, + String description, + ShouldGenerate shouldGenerate + ) { + super(parent, className, typedefName, description, shouldGenerate); this.valueBodyField = new Field("_value_body", arrayType, true, "Response value.", null); } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/DictionaryResponseShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/DictionaryResponseShape.java new file mode 100644 index 0000000000..377cc33301 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/DictionaryResponseShape.java @@ -0,0 +1,43 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.codegen.model; + +import java.util.Collection; +import java.util.List; +import org.opensearch.client.codegen.model.overrides.ShouldGenerate; + +public class DictionaryResponseShape extends Shape { + private final Type keyType; + private final Type valueType; + + public DictionaryResponseShape( + Namespace parent, + String className, + String typedefName, + String description, + Type keyType, + Type valueType, + ShouldGenerate shouldGenerate + ) { + super(parent, className, typedefName, description, shouldGenerate); + this.keyType = keyType; + this.valueType = valueType; + setExtendsType(Types.Client.Transport.Endpoints.DictionaryResponse(keyType, valueType)); + } + + @Override + public Collection getAnnotations() { + return List.of(Types.Client.Json.JsonpDeserializable); + } + + @Override + public boolean extendsOtherShape() { + return true; + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java index 0968bd9886..c33b7da0f8 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/EnumShape.java @@ -9,17 +9,21 @@ package org.opensearch.client.codegen.model; import java.util.Collection; -import java.util.Collections; +import java.util.HashSet; import java.util.List; +import java.util.Set; +import java.util.TreeMap; +import javax.annotation.Nullable; +import org.opensearch.client.codegen.model.overrides.ShouldGenerate; import org.opensearch.client.codegen.utils.JavaClassKind; +import org.opensearch.client.codegen.utils.Markdown; import org.opensearch.client.codegen.utils.Strings; public class EnumShape extends Shape { - private final List variants; + private final TreeMap variants = new TreeMap<>(); - public EnumShape(Namespace parent, String className, List variants, String typedefName, String description) { - super(parent, className, typedefName, description); - this.variants = variants; + public EnumShape(Namespace parent, String className, String typedefName, String description, ShouldGenerate shouldGenerate) { + super(parent, className, typedefName, description, shouldGenerate); } @Override @@ -37,16 +41,37 @@ public Collection getImplementsTypes() { return List.of(Types.Client.Json.JsonEnum); } + public void addVariant(String value, String description, boolean deprecated) { + var variant = variants.get(value.toLowerCase()); + if (variant == null) { + variant = new Variant(value, description, deprecated); + variants.put(value.toLowerCase(), variant); + } else { + variant.addAlias(value); + variant.setDeprecated(variant.isDeprecated() || deprecated); + if (description != null) { + variant.setDescription(description); + } + } + } + public Collection getVariants() { - return Collections.unmodifiableCollection(variants); + return variants.values(); + } + + public boolean anyHasAliases() { + return variants.values().stream().anyMatch(v -> !v.getAliases().isEmpty()); } public static class Variant { private final String wireName; - private final boolean deprecated; + private final Set aliases = new HashSet<>(); + private boolean deprecated; + private String description; - public Variant(String wireName, boolean deprecated) { + public Variant(String wireName, String description, boolean deprecated) { this.wireName = wireName; + setDescription(description); this.deprecated = deprecated; } @@ -54,6 +79,22 @@ public String getWireName() { return wireName; } + public String getDescription() { + return description; + } + + public void setDescription(@Nullable String description) { + this.description = description != null ? Markdown.toJavaDocHtml(description) : null; + } + + public Set getAliases() { + return aliases; + } + + public void addAlias(String alias) { + aliases.add(alias); + } + public String getName() { return Strings.toPascalCase(wireName); } @@ -61,5 +102,9 @@ public String getName() { public boolean isDeprecated() { return deprecated; } + + public void setDeprecated(boolean deprecated) { + this.deprecated = deprecated; + } } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java index e4d1734572..62eabd6273 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java @@ -8,10 +8,13 @@ package org.opensearch.client.codegen.model; +import java.util.HashSet; import java.util.Objects; +import java.util.Set; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.opensearch.client.codegen.NameSanitizer; +import org.opensearch.client.codegen.utils.Markdown; +import org.opensearch.client.codegen.utils.NameSanitizer; import org.opensearch.client.codegen.utils.Strings; public class Field { @@ -25,6 +28,7 @@ public class Field { @Nullable private final Deprecation deprecation; private final boolean isAdditionalProperties; + private final Set aliases = new HashSet<>(); public Field( @Nonnull String wireName, @@ -47,7 +51,7 @@ public Field( this.wireName = Strings.requireNonBlank(wireName, "wireName must not be null"); this.type = Objects.requireNonNull(type, "type must not be null"); this.required = required; - this.description = description; + this.description = description != null ? Markdown.toJavaDocHtml(description) : null; this.deprecation = deprecation; this.isAdditionalProperties = isAdditionalProperties; } @@ -84,4 +88,8 @@ public String getDescription() { public Deprecation getDeprecation() { return deprecation; } + + public void addAlias(String alias) { + aliases.add(alias); + } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java index e0e3861bcc..1416a707d4 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Namespace.java @@ -19,11 +19,12 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.builder.ToStringBuilder; import org.opensearch.client.codegen.exceptions.RenderException; +import org.opensearch.client.codegen.model.overrides.ShouldGenerate; import org.opensearch.client.codegen.utils.Lists; import org.opensearch.client.codegen.utils.Strings; public class Namespace { - private static final Set PARTIAL_NAMESPACES = Set.of(""); + private static final Set PARTIAL_NAMESPACES = Set.of("", "snapshot", "indices"); private final Namespace parent; private final String name; @@ -104,13 +105,24 @@ private Type getClientType(boolean async) { return Type.builder().withPackage(getPackageName()).withName(getClientClassName(async, false)).build(); } + @Override + public String toString() { + return getPackageName(); + } + private static class Client extends Shape { private final boolean async; private final boolean base; private final Collection operations; private Client(Namespace parent, boolean async, boolean base, Collection operations) { - super(parent, parent.getClientClassName(async, base), null, "Client for the " + parent.name + " namespace."); + super( + parent, + parent.getClientClassName(async, base), + null, + "Client for the " + parent.name + " namespace.", + ShouldGenerate.Always + ); this.async = async; this.base = base; this.operations = operations; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java index 32ba374de0..3cbabe8754 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java @@ -10,16 +10,22 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Comparator; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.TreeMap; +import java.util.stream.Collectors; +import org.apache.commons.lang3.tuple.Pair; +import org.opensearch.client.codegen.model.overrides.ShouldGenerate; public class ObjectShape extends Shape { protected final Map bodyFields = new TreeMap<>(); protected Field additionalPropertiesField; + private String shortcutProperty; - public ObjectShape(Namespace parent, String className, String typedefName, String description) { - super(parent, className, typedefName, description); + public ObjectShape(Namespace parent, String className, String typedefName, String description, ShouldGenerate shouldGenerate) { + super(parent, className, typedefName, description, shouldGenerate); } public void addBodyField(Field field) { @@ -28,7 +34,14 @@ public void addBodyField(Field field) { } public Collection getBodyFields() { - return bodyFields.values(); + var discriminatingFields = getReferencingDiscriminatedUnions().stream() + .map(ReferencingDiscriminatedUnion::getDiscriminatingField) + .collect(Collectors.toSet()); + if (!discriminatingFields.isEmpty()) { + return bodyFields.values().stream().filter(f -> !discriminatingFields.contains(f.getWireName())).collect(Collectors.toList()); + } else { + return bodyFields.values(); + } } public Collection getFields() { @@ -51,23 +64,83 @@ public Field getAdditionalPropertiesField() { return additionalPropertiesField; } + public String getShortcutProperty() { + return shortcutProperty; + } + + public void setShortcutProperty(String shortcutProperty) { + this.shortcutProperty = shortcutProperty; + } + public boolean hasFieldsToSerialize() { return !bodyFields.isEmpty() || additionalPropertiesField != null; } - public boolean hasFields() { - return !bodyFields.isEmpty() || additionalPropertiesField != null; + public Collection getReferencingDiscriminatedUnions() { + return getIncomingReference(ReferenceKind.UnionVariant).stream() + .map(s -> (TaggedUnionShape) s) + .filter(TaggedUnionShape::isDiscriminated) + .sorted(Comparator.comparing(Shape::getClassName)) + .map(u -> { + var discriminatorValue = u.getVariants() + .stream() + .filter(v -> v.getType().equals(getType())) + .findFirst() + .orElseThrow() + .getName(); + + return new ReferencingDiscriminatedUnion(u, discriminatorValue); + }) + .collect(Collectors.toList()); + } + + public Set> getDistinctDiscriminatorFieldValues() { + return getReferencingDiscriminatedUnions().stream() + .map(u -> Pair.of(u.getDiscriminatingField(), u.getDiscriminatorValue())) + .collect(Collectors.toSet()); } public Collection getImplementsTypes() { - return hasFieldsToSerialize() && !extendsOtherShape() ? List.of(Types.Client.Json.PlainJsonSerializable) : null; + var types = new ArrayList(2); + + for (var union : getReferencingDiscriminatedUnions()) { + types.add(union.getUnion().getVariantBaseType()); + } + + if (hasFieldsToSerialize() && !extendsOtherShape()) { + types.add(Types.Client.Json.PlainJsonSerializable); + } + + return types; } public Collection getAnnotations() { return (hasFieldsToSerialize() || extendsOtherShape()) && !isAbstract() ? List.of(Types.Client.Json.JsonpDeserializable) : null; } - public static class BuilderModel { + public boolean shouldImplementPlainDeserializable() { + return Set.of("SourceField", "TypeMapping").contains(getClassName()); + } + + public static class ReferencingDiscriminatedUnion { + private final TaggedUnionShape union; + private final String discriminatorValue; + + public ReferencingDiscriminatedUnion(TaggedUnionShape union, String discriminatorValue) { + this.union = union; + this.discriminatorValue = discriminatorValue; + } + public TaggedUnionShape getUnion() { + return union; + } + + public String getDiscriminatingField() { + return union.getDiscriminatingField(); + } + + public String getDiscriminatorValue() { + return discriminatorValue; + } } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ReferenceKind.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ReferenceKind.java index 19a92dd6fb..b9ca519856 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ReferenceKind.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ReferenceKind.java @@ -11,7 +11,8 @@ public enum ReferenceKind { Extends(false), Field(true), - UnionVariant(true); + UnionVariant(true), + TypeParameter(true); private final boolean isConcreteUsage; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java index d76a67d2fe..df8ffabe6f 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/RequestShape.java @@ -19,6 +19,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.apache.commons.lang3.tuple.Pair; +import org.opensearch.client.codegen.model.overrides.ShouldGenerate; import org.opensearch.client.codegen.utils.Streams; import org.opensearch.client.codegen.utils.Strings; @@ -35,9 +36,15 @@ public class RequestShape extends ObjectShape { private final Map pathParams = new TreeMap<>(); @Nonnull private final Map fields = new TreeMap<>(); - - public RequestShape(@Nonnull Namespace parent, @Nonnull OperationGroup operationGroup, @Nullable String description) { - super(parent, requestClassName(operationGroup), operationGroup.asTypedefPrefix() + ".Request", description); + private boolean isBooleanRequest; + + public RequestShape( + @Nonnull Namespace parent, + @Nonnull OperationGroup operationGroup, + @Nullable String description, + @Nonnull ShouldGenerate shouldGenerate + ) { + super(parent, requestClassName(operationGroup), operationGroup.asTypedefPrefix() + ".Request", description, shouldGenerate); this.operationGroup = operationGroup; } @@ -72,8 +79,18 @@ public void addSupportedHttpMethod(String method) { httpMethods.add(method); } + public void setIsBooleanRequest() { + isBooleanRequest = true; + } + + public boolean isBooleanRequest() { + return isBooleanRequest; + } + public Type getResponseType() { - return Type.builder().withPackage(getPackageName()).withName(responseClassName(operationGroup)).build(); + return !isBooleanRequest + ? Type.builder().withPackage(getPackageName()).withName(responseClassName(operationGroup)).build() + : Types.Client.Transport.Endpoints.BooleanResponse; } public boolean canBeSingleton() { @@ -151,10 +168,6 @@ public boolean hasAnyRequiredFields() { return fields.values().stream().anyMatch(Field::isRequired); } - public boolean hasFields() { - return !fields.isEmpty(); - } - public Type getJsonEndpointType() { return Types.Client.Transport.JsonEndpoint(getType(), getResponseType(), Types.Client.OpenSearch._Types.ErrorResponse); } @@ -173,6 +186,14 @@ private static String responseClassName(@Nonnull OperationGroup operationGroup) private static String classBaseName(@Nonnull OperationGroup operationGroup) { Objects.requireNonNull(operationGroup, "operationGroup must not be null"); switch (operationGroup.toString()) { + case "indices.create": + return "CreateIndex"; + case "indices.delete": + return "DeleteIndex"; + case "indices.get": + return "GetIndex"; + case "snapshot.clone": + return "CloneSnapshot"; case "tasks.get": return "GetTasks"; default: diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java index c44c8d72d9..e1e834480f 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Shape.java @@ -19,10 +19,13 @@ import java.util.TreeSet; import java.util.stream.Collectors; import javax.annotation.Nonnull; +import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.client.codegen.exceptions.RenderException; +import org.opensearch.client.codegen.model.overrides.ShouldGenerate; import org.opensearch.client.codegen.utils.JavaClassKind; +import org.opensearch.client.codegen.utils.Markdown; public abstract class Shape { private static final Logger LOGGER = LogManager.getLogger(); @@ -33,13 +36,15 @@ public abstract class Shape { private final String className; private final String typedefName; private final String description; + private final ShouldGenerate shouldGenerate; private Type extendsType; - public Shape(Namespace parent, String className, String typedefName, String description) { + public Shape(Namespace parent, String className, String typedefName, String description, ShouldGenerate shouldGenerate) { this.parent = parent; this.className = className; this.typedefName = typedefName; - this.description = description; + this.description = description != null ? Markdown.toJavaDocHtml(description) : null; + this.shouldGenerate = shouldGenerate; } public String getPackageName() { @@ -103,6 +108,12 @@ public Collection getImplementsTypes() { protected void tryAddReference(ReferenceKind kind, Type to) { if (to == null) return; to.getTargetShape().ifPresent(s -> addReference(kind, s)); + var typeParams = to.getTypeParams(); + if (typeParams != null) { + for (var typeParam : typeParams) { + tryAddReference(ReferenceKind.TypeParameter, typeParam); + } + } } private void addReference(ReferenceKind kind, Shape to) { @@ -110,6 +121,11 @@ private void addReference(ReferenceKind kind, Shape to) { to.incomingReferences.computeIfAbsent(kind, k -> new ArrayList<>()).add(this); } + protected Collection getIncomingReference(ReferenceKind kind) { + var refs = incomingReferences.get(kind); + return refs != null ? Collections.unmodifiableList(refs) : Collections.emptyList(); + } + public @Nonnull Type getType() { return Type.builder().withPackage(getPackageName()).withName(className).withTargetShape(this).build(); } @@ -118,8 +134,33 @@ public Namespace getParent() { return this.parent; } + private boolean shouldGenerate(Set visited) { + switch (shouldGenerate) { + case Always: + return true; + case Never: + return false; + case IfNeeded: + if (visited.contains(this)) { + return false; + } + visited.add(this); + return incomingReferences.values().stream().flatMap(List::stream).anyMatch(s -> s.shouldGenerate(visited)); + default: + throw new IllegalStateException("Unknown ShouldGenerate: " + shouldGenerate); + } + } + + public boolean shouldGenerate() { + return shouldGenerate(new HashSet<>()); + } + public void render(ShapeRenderingContext ctx) throws RenderException { var outFile = ctx.getOutputFile(className + ".java"); + if (!shouldGenerate()) { + LOGGER.info("Skipping: {}", outFile); + return; + } LOGGER.info("Rendering: {}", outFile); var renderer = ctx.getTemplateRenderer(b -> b.withFormatter(Type.class, t -> { referencedTypes.add(t); @@ -128,6 +169,10 @@ public void render(ShapeRenderingContext ctx) throws RenderException { renderer.renderJava(this, outFile); } + public String getTemplateName() { + return getClass().getSimpleName(); + } + public Set getImports() { var imports = new TreeSet(); for (var type : referencedTypes) { @@ -137,6 +182,17 @@ public Set getImports() { } public boolean needsLegacyLicense() { + if ("analysis".equals(parent.getName()) && (className.startsWith("Cjk") || className.startsWith("Smartcn"))) { + return false; + } return !"ml".equals(parent.getName()); } + + @Override + public String toString() { + return new ToStringBuilder(this).append("className", className) + .append("parent", parent) + .append("extendsType", extendsType) + .toString(); + } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ShapeRenderingContext.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ShapeRenderingContext.java index 72a163ea3b..1f6ab5ce15 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ShapeRenderingContext.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ShapeRenderingContext.java @@ -16,8 +16,8 @@ import org.opensearch.client.codegen.renderer.TemplateLoader; import org.opensearch.client.codegen.renderer.TemplateRenderer; import org.opensearch.client.codegen.renderer.TemplateValueFormatter; -import org.opensearch.client.codegen.utils.ObjectBuilderBase; import org.opensearch.client.codegen.utils.Strings; +import org.opensearch.client.codegen.utils.builder.ObjectBuilderBase; public final class ShapeRenderingContext implements AutoCloseable { @Nonnull diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java index 575a955811..7983ec9df4 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/SpecTransformer.java @@ -11,7 +11,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -28,10 +27,13 @@ import org.apache.logging.log4j.Logger; import org.opensearch.client.codegen.model.overrides.Overrides; import org.opensearch.client.codegen.model.overrides.PropertyOverride; +import org.opensearch.client.codegen.model.overrides.SchemaOverride; +import org.opensearch.client.codegen.model.overrides.ShouldGenerate; import org.opensearch.client.codegen.openapi.HttpStatusCode; import org.opensearch.client.codegen.openapi.In; import org.opensearch.client.codegen.openapi.JsonPointer; import org.opensearch.client.codegen.openapi.MimeType; +import org.opensearch.client.codegen.openapi.OpenApiDiscriminator; import org.opensearch.client.codegen.openapi.OpenApiMediaType; import org.opensearch.client.codegen.openapi.OpenApiOperation; import org.opensearch.client.codegen.openapi.OpenApiParameter; @@ -43,6 +45,7 @@ import org.opensearch.client.codegen.openapi.OpenApiSchemaFormat; import org.opensearch.client.codegen.openapi.OpenApiSchemaType; import org.opensearch.client.codegen.openapi.OpenApiSpecification; +import org.opensearch.client.codegen.utils.Maps; import org.opensearch.client.codegen.utils.Versions; public class SpecTransformer { @@ -92,6 +95,13 @@ public void visit(@Nonnull OpenApiSpecification spec) { }); groupedOperations.forEach(this::visit); + + overrides.getSchemas().forEach((pointer, schemaOverride) -> { + if (schemaOverride.shouldGenerate() != ShouldGenerate.Always) { + return; + } + visit(spec.getElement(pointer, OpenApiSchema.class)); + }); } private void visit(@Nonnull OperationGroup group, @Nonnull List variants) { @@ -120,10 +130,20 @@ private void visit(@Nonnull OperationGroup group, @Nonnull List c.get(MimeType.Json)) .flatMap(OpenApiMediaType::getSchema) .map(OpenApiSchema::resolve) - .orElse(OpenApiSchema.ANONYMOUS_OBJECT); - - visitInto(bodySchema, shape); + .ifPresent(s -> visitInto(s, shape)); if (shape.getExtendsType() == null) { shape.setExtendsType(Types.Client.OpenSearch._Types.RequestBase); @@ -235,10 +253,13 @@ private Field visit(OpenApiParameter parameter) { private Shape visit(OpenApiSchema schema) { var namespace = schema.getNamespace().orElseThrow(); var name = schema.getName().orElseThrow(); - return visit(root.child(namespace), name, namespace + "." + name, schema); + var schemaOverrides = overrides.getSchema(schema.getPointer()); + var className = schemaOverrides.flatMap(SchemaOverride::getClassName).orElse(name); + var shouldGenerate = schemaOverrides.map(SchemaOverride::shouldGenerate).orElse(ShouldGenerate.IfNeeded); + return visit(root.child(namespace), className, namespace + "." + name, schema, shouldGenerate); } - private Shape visit(Namespace parent, String className, String typedefName, OpenApiSchema schema) { + private Shape visit(Namespace parent, String className, String typedefName, OpenApiSchema schema, ShouldGenerate shouldGenerate) { Shape shape = visitedSchemas.get(schema); if (shape != null) { @@ -249,43 +270,73 @@ private Shape visit(Namespace parent, String className, String typedefName, Open var description = schema.getDescription().orElse(null); - var oneOf = schema.getOneOf(); + var isTaggedUnion = isTaggedUnion(schema); + var isShortcutPropertyObject = isShortcutPropertyObject(schema); if (schema.isArray()) { - shape = new ArrayShape(parent, className, mapType(schema), typedefName, description); + shape = new ArrayShape(parent, className, mapType(schema), typedefName, description, shouldGenerate); visitedSchemas.putIfAbsent(schema, shape); - } else if (schema.isStringEnum() || (oneOf.isPresent() && oneOf.get().stream().allMatch(OpenApiSchema::isStringEnum))) { - var variants = new ArrayList(); - - if (oneOf.isPresent()) { - oneOf.get().forEach(s -> { - var isDeprecated = s.getVersionDeprecated().isPresent(); - s.getEnums().orElseThrow().forEach(v -> variants.add(new EnumShape.Variant(v, isDeprecated))); - }); - } else { - schema.getEnums().orElseThrow().forEach(v -> variants.add(new EnumShape.Variant(v, false))); - } - - variants.sort(Comparator.comparing(EnumShape.Variant::getName)); - - shape = new EnumShape(parent, className, variants, typedefName, description); + } else if (isEnum(schema)) { + var enumShape = new EnumShape(parent, className, typedefName, description, shouldGenerate); + shape = enumShape; visitedSchemas.putIfAbsent(schema, shape); - } else if (oneOf.isPresent()) { - var taggedUnion = new TaggedUnionShape(parent, className, typedefName, description); + + visitInto(schema, enumShape); + } else if (isTaggedUnion) { + var discriminatingField = schema.getDiscriminator().flatMap(OpenApiDiscriminator::getPropertyName).orElse(null); + var taggedUnion = new TaggedUnionShape(parent, className, typedefName, description, discriminatingField, shouldGenerate); shape = taggedUnion; visitedSchemas.putIfAbsent(schema, shape); - oneOf.get().forEach(s -> { - var title = s.getTitle() - .orElseThrow(() -> new IllegalStateException("oneOf variant [" + s.getPointer() + "] is missing a `title` tag")); - taggedUnion.addVariant(title, mapType(s)); + schema.getOneOf().or(schema::getAnyOf).orElseThrow().forEach(s -> { + String name; + if (discriminatingField != null) { + var props = new HashMap(); + collectObjectProperties(s, props, new ArrayList<>()); + name = Maps.tryGet(props, discriminatingField) + .flatMap(OpenApiSchema::getEnums) + .flatMap(enums -> enums.stream().findFirst()) + .orElseThrow( + () -> new IllegalStateException( + "oneOf variant [" + + s.getPointer() + + "] is missing the `" + + discriminatingField + + "` property as a single value enum" + ) + ); + } else { + name = s.getTitle() + .orElseThrow(() -> new IllegalStateException("oneOf variant [" + s.getPointer() + "] is missing a `title` tag")); + } + taggedUnion.addVariant(name, mapType(s)); }); - } else if (schema.determineSingleType().orElse(null) == OpenApiSchemaType.Object) { - var objShape = new ObjectShape(parent, className, typedefName, description); - shape = objShape; - visitedSchemas.putIfAbsent(schema, shape); + } else if (isShortcutPropertyObject || schema.determineSingleType().orElse(null) == OpenApiSchemaType.Object) { + if (schema.getProperties().isEmpty() && schema.getAdditionalProperties().isPresent()) { + shape = new DictionaryResponseShape( + parent, + className, + typedefName, + description, + Types.Java.Lang.String, + mapType(schema.getAdditionalProperties().orElseThrow()), + shouldGenerate + ); + visitedSchemas.putIfAbsent(schema, shape); + } else { + var objShape = new ObjectShape(parent, className, typedefName, description, shouldGenerate); + shape = objShape; + visitedSchemas.putIfAbsent(schema, shape); + + if (isShortcutPropertyObject) { + var oneOf = schema.getOneOf().orElseThrow(); + var shortcutProperty = oneOf.get(0).getTitle().orElseThrow(); + objShape.setShortcutProperty(shortcutProperty); + schema = oneOf.get(1); + } - visitInto(schema, objShape); + visitInto(schema, objShape); + } } else { throw new NotImplementedException("Unsupported schema: " + schema); } @@ -310,8 +361,15 @@ private void visitInto(OpenApiSchema schema, ObjectShape shape) { final var overrides = this.overrides.getSchema(schema.getPointer()); properties.forEach((k, v) -> { - var type = overrides.flatMap(so -> so.getProperty(k)).flatMap(PropertyOverride::getMappedType).orElseGet(() -> mapType(v)); - shape.addBodyField(new Field(k, type, required.contains(k), v.getDescription().orElse(null), null)); + var propOverrides = overrides.map(so -> so.getProperty(k)); + + var type = propOverrides.flatMap(PropertyOverride::getMappedType).orElseGet(() -> mapType(v)); + + var field = new Field(k, type, required.contains(k), v.getDescription().orElse(null), null); + + propOverrides.flatMap(PropertyOverride::getAliases).ifPresent(aliases -> aliases.forEach(field::addAlias)); + + shape.addBodyField(field); }); if (!additionalProperties.isEmpty()) { @@ -329,7 +387,7 @@ private void visitInto(OpenApiSchema schema, ObjectShape shape) { } } - private Set collectObjectProperties( + private static Set collectObjectProperties( OpenApiSchema schema, Map properties, List additionalProperties @@ -388,6 +446,21 @@ private Set collectObjectProperties( return schema.getRequired().orElseGet(Collections::emptySet); } + private void visitInto(OpenApiSchema schema, EnumShape shape) { + var isDeprecated = schema.getVersionDeprecated().isPresent(); + + if (schema.hasOneOf()) { + schema.getOneOf().orElseThrow().forEach(s -> visitInto(s, shape)); + } else if (schema.hasEnums()) { + var enums = schema.getEnums().orElseThrow(); + var description = enums.size() == 1 ? schema.getDescription().orElse(null) : null; + enums.forEach(v -> shape.addVariant(v, description, isDeprecated)); + } else if (schema.hasConst()) { + var value = (String) schema.getConst().orElseThrow(); + shape.addVariant(value, schema.getDescription().orElse(null), isDeprecated); + } + } + private Type mapType(OpenApiSchema schema) { return mapType(schema, false); } @@ -402,9 +475,22 @@ private Type mapType(OpenApiSchema schema, boolean boxed) { } private Type mapTypeInner(OpenApiSchema schema) { + if (schema.getPointer().isDirectChildOf(JsonPointer.of("components", "schemas"))) { + var type = mapTypeComponentsSchemas(schema); + if (type != null) { + return type; + } + } + if (schema.has$ref()) { schema = schema.resolve(); + var overriddenMappedType = overrides.getSchema(schema.getPointer()).flatMap(SchemaOverride::getMappedType); + + if (overriddenMappedType.isPresent()) { + return overriddenMappedType.get(); + } + if (!shouldKeepRef(schema)) { return mapType(schema); } @@ -436,7 +522,6 @@ private Type mapTypeInner(OpenApiSchema schema) { case Array: return mapArray(schema); case String: - if ("_common:Duration".equals(schema.getPointer().getLastKey().orElse(null))) return Types.Client.OpenSearch._Types.Time; return Types.Java.Lang.String; case Boolean: return Types.Primitive.Boolean; @@ -449,6 +534,22 @@ private Type mapTypeInner(OpenApiSchema schema) { throw new UnsupportedOperationException("Can not get type name for: " + types); } + private Type mapTypeComponentsSchemas(OpenApiSchema schema) { + var key = schema.getPointer().getLastKey().orElseThrow(); + switch (key) { + case "_common:Duration": + return Types.Client.OpenSearch._Types.Time; + case "_common:Stringifiedinteger": + return Types.Primitive.Int; + case "_common:Stringifiedboolean": + return Types.Primitive.Boolean; + case "_common:StringifiedEpochTimeUnitMillis": + return Types.Primitive.Long; + default: + return null; + } + } + private Type mapOneOf(List oneOf) { if (isOneOfSingleAndArray(oneOf)) { return mapType(oneOf.get(1)); @@ -464,7 +565,7 @@ private Type mapOneOf(List oneOf) { return Types.Java.Lang.String; } - throw new UnsupportedOperationException("Can not get type name for oneOf: " + oneOf); + return Types.Client.Json.JsonData; } private Type mapAllOf(List allOf) { @@ -500,7 +601,10 @@ private Type mapInteger(OpenApiSchema schema) { } private Type mapNumber(OpenApiSchema schema) { - var format = schema.getFormat().orElse(OpenApiSchemaFormat.Float); + var format = schema.getFormat().orElse(null); + if (format == null) { + return Types.Java.Lang.Number; + } switch (format) { case Float: return Types.Primitive.Float; @@ -514,25 +618,27 @@ private Type mapNumber(OpenApiSchema schema) { } private boolean shouldKeepRef(OpenApiSchema schema) { - if (schema.isInteger() || schema.isNumber() || schema.isArray()) { + if (schema.isArray() || schema.isBoolean() || schema.isInteger() || schema.isNumber()) { return false; } + if (isEnum(schema)) { + return true; + } if (schema.isString()) { - return schema.hasEnums(); + return false; } if (schema.isObject() && schema.getProperties().map(Map::isEmpty).orElse(true) && schema.getAdditionalProperties().map(s -> s.getTitle().isEmpty()).orElse(false)) { return false; } - if (schema.getOneOf().isPresent()) { - var oneOf = schema.getOneOf().orElseThrow(); - return oneOf.stream().allMatch(s -> s.getTitle().isPresent()) || oneOf.stream().allMatch(OpenApiSchema::isStringEnum); + if (isTaggedUnion(schema)) { + return true; } - if (schema.getAllOf().isPresent()) { - return schema.determineSingleType().orElse(null) == OpenApiSchemaType.Object; + if (isShortcutPropertyObject(schema)) { + return true; } - return true; + return schema.determineSingleType().orElse(null) == OpenApiSchemaType.Object; } private static boolean isOneOfSingleAndArray(List oneOf) { @@ -547,4 +653,56 @@ private static boolean isOneOfSingleAndArray(List oneOf) { var items = second.getItems().orElseThrow(); return first.getTypes().equals(items.getTypes()) && first.get$ref().equals(items.get$ref()); } + + private static boolean isEnum(OpenApiSchema schema) { + if (schema.isString()) { + return schema.hasEnums() || schema.hasConst(); + } + if (schema.getOneOf().isPresent()) { + return schema.getOneOf().get().stream().allMatch(SpecTransformer::isEnum); + } + return false; + } + + private static boolean isShortcutPropertyObject(OpenApiSchema schema) { + var oneOf = schema.getOneOf().orElse(null); + + if (oneOf == null || oneOf.size() != 2) { + return false; + } + + var first = oneOf.get(0); + var second = oneOf.get(1); + + if (!first.hasTitle() || second.hasTitle()) { + return false; + } + + var secondType = second.determineSingleType().orElse(null); + if (secondType != OpenApiSchemaType.Object) { + return false; + } + + var properties = new HashMap(); + collectObjectProperties(second, properties, new ArrayList<>()); + + return properties.containsKey(first.getTitle().orElseThrow()); + } + + private static boolean isTaggedUnion(OpenApiSchema schema) { + if (schema.hasOneOf()) { + if (schema.getDiscriminator().isPresent()) { + return true; + } + return isTaggedUnion(schema.getOneOf().orElseThrow()); + } + if (schema.hasAnyOf()) { + return isTaggedUnion(schema.getAnyOf().orElseThrow()); + } + return false; + } + + private static boolean isTaggedUnion(List oneOfAnyOf) { + return oneOfAnyOf.stream().allMatch(OpenApiSchema::hasTitle); + } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/TaggedUnionShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/TaggedUnionShape.java index cc3d28ff7c..7214c6c374 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/TaggedUnionShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/TaggedUnionShape.java @@ -8,29 +8,48 @@ package org.opensearch.client.codegen.model; -import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.opensearch.client.codegen.exceptions.RenderException; +import org.opensearch.client.codegen.model.overrides.ShouldGenerate; +import org.opensearch.client.codegen.utils.JavaClassKind; import org.opensearch.client.codegen.utils.Lists; +import org.opensearch.client.codegen.utils.Strings; -public class TaggedUnionShape extends ObjectShape { - private final List variants = new ArrayList<>(); +public class TaggedUnionShape extends Shape { + private final Map variants = new TreeMap<>(); + private final String discriminatingField; - public TaggedUnionShape(Namespace parent, String className, String typedefName, String description) { - super(parent, className, typedefName, description); + public TaggedUnionShape( + Namespace parent, + String className, + String typedefName, + String description, + String discriminatingField, + ShouldGenerate shouldGenerate + ) { + super(parent, className, typedefName, description, shouldGenerate); + this.discriminatingField = discriminatingField; } public void addVariant(String name, Type type) { - variants.add(new Variant(name, type.getBoxed())); + variants.put(name, new Variant(name, type.getBoxed())); tryAddReference(ReferenceKind.UnionVariant, type); } public Collection getVariants() { - return variants; + return variants.values(); } - public Collection getPrimitiveVariants() { - return Lists.filter(variants, v -> v.getType().isPrimitive()); + public Collection getNonShapeVariants() { + return Lists.filter(getVariants(), v -> !v.getType().isInsidePackage("org.opensearch")); + } + + public Variant getDefaultVariant() { + return variants.get("custom"); } @Override @@ -41,11 +60,58 @@ public Collection getAnnotations() { @Override public Collection getImplementsTypes() { return List.of( - Types.Client.Util.TaggedUnion(getType().getNestedType("Kind"), Types.Java.Lang.Object), + Types.Client.Util.TaggedUnion(getType().getNestedType("Kind"), getVariantBaseType()), Types.Client.Json.PlainJsonSerializable ); } + public boolean isDiscriminated() { + return discriminatingField != null; + } + + public String getDiscriminatingField() { + return discriminatingField; + } + + public Type getVariantBaseType() { + return isDiscriminated() + ? Type.builder().withPackage(getPackageName()).withName(getClassName() + "Variant").build() + : Types.Java.Lang.Object; + } + + public boolean canStringify() { + return !isDiscriminated() && getVariants().stream().allMatch(v -> { + var t = v.getType(); + return t.isPotentiallyBoxedPrimitive() || t.isString() || t.isEnum(); + }); + } + + public boolean hasAmbiguities() { + if (isDiscriminated()) { + return false; + } + + return getVariants().stream().filter(v -> { + var t = v.getType(); + return t.isString() || t.isEnum(); + }).count() > 1; + } + + @Override + public void render(ShapeRenderingContext ctx) throws RenderException { + if (!shouldGenerate()) { + return; + } + super.render(ctx); + var buildableVariants = Lists.filter(getVariants(), v -> v.getType().hasBuilder()); + if (!buildableVariants.isEmpty()) { + new Builders(this, buildableVariants, ShouldGenerate.Always).render(ctx); + } + if (isDiscriminated()) { + new VariantInterface(this, ShouldGenerate.Always).render(ctx); + } + } + public static class Variant { private final String name; private final Type type; @@ -62,5 +128,87 @@ public String getName() { public Type getType() { return type; } + + @Override + public String toString() { + return new ToStringBuilder(this).append("name", name).append("type", type).toString(); + } + } + + public static class Builders extends Shape { + private static String buildDescription(TaggedUnionShape union) { + var desc = "Builders for {@link " + union.getClassName() + "} variants."; + var nonShapeVariants = union.getNonShapeVariants(); + if (!nonShapeVariants.isEmpty()) { + desc += "\n\nVariants "; + desc += Strings.join(nonShapeVariants, ", ", v -> "`" + v.getName() + "`"); + desc += " are not available here as they don't have a dedicated class. Use {@link " + + union.getClassName() + + "}'s builder for these."; + } + return desc; + } + + private final String unionClassName; + private final Collection variants; + + private Builders(TaggedUnionShape union, Collection variants, ShouldGenerate shouldGenerate) { + super(union.getParent(), union.getClassName() + "Builders", null, buildDescription(union), shouldGenerate); + this.variants = variants; + unionClassName = union.getClassName(); + } + + public String getUnionClassName() { + return unionClassName; + } + + public Collection getVariants() { + return variants; + } + + @Override + public String getTemplateName() { + return "TaggedUnionShape/Builders"; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("unionClassName", unionClassName).append("variants", variants).toString(); + } + } + + public static class VariantInterface extends Shape { + private final String unionClassName; + + private VariantInterface(TaggedUnionShape union, ShouldGenerate shouldGenerate) { + super( + union.getParent(), + union.getClassName() + "Variant", + null, + "Base interface for {@link " + union.getClassName() + "} variants.", + shouldGenerate + ); + unionClassName = union.getClassName(); + setExtendsType(Types.Client.Json.JsonpSerializable); + } + + @Override + public JavaClassKind getClassKind() { + return JavaClassKind.Interface; + } + + public String getUnionClassName() { + return unionClassName; + } + + @Override + public String getTemplateName() { + return "TaggedUnionShape/VariantInterface"; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("unionClassName", unionClassName).toString(); + } } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java index f46c3f0306..38bcd76d82 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Type.java @@ -16,11 +16,13 @@ import java.util.Set; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; import org.opensearch.client.codegen.renderer.lambdas.TypeIsDefinedLambda; import org.opensearch.client.codegen.renderer.lambdas.TypeQueryParamifyLambda; import org.opensearch.client.codegen.renderer.lambdas.TypeSerializerLambda; -import org.opensearch.client.codegen.utils.ObjectBuilderBase; import org.opensearch.client.codegen.utils.Strings; +import org.opensearch.client.codegen.utils.builder.ObjectBuilderBase; public class Type { private static final Set PRIMITIVES = Set.of("boolean", "char", "byte", "short", "int", "long", "float", "double"); @@ -70,11 +72,40 @@ public String toString() { return out.toString(); } + @Override + public boolean equals(Object o) { + if (this == o) return true; + + if (o == null || getClass() != o.getClass()) return false; + + Type type = (Type) o; + + return new EqualsBuilder().append(packageName, type.packageName) + .append(name, type.name) + .append(typeParams, type.typeParams) + .append(targetShape, type.targetShape) + .isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 37).append(packageName).append(name).append(typeParams).append(targetShape).toHashCode(); + } + @Nonnull public String getName() { return name; } + @Nullable + public Type[] getTypeParams() { + return typeParams; + } + + public boolean isInsidePackage(String pkg) { + return packageName != null && packageName.startsWith(pkg); + } + @Nonnull public Type getBoxed() { switch (name) { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/TypeParameterDefinition.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/TypeParameterDefinition.java index 76935c0273..f4316f37b2 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/TypeParameterDefinition.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/TypeParameterDefinition.java @@ -10,8 +10,8 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.opensearch.client.codegen.utils.ObjectBuilderBase; import org.opensearch.client.codegen.utils.Strings; +import org.opensearch.client.codegen.utils.builder.ObjectBuilderBase; public final class TypeParameterDefinition { @Nonnull diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/TypeParameterDiamond.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/TypeParameterDiamond.java index 074452d78a..50725ff100 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/TypeParameterDiamond.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/TypeParameterDiamond.java @@ -12,7 +12,7 @@ import java.util.function.Function; import javax.annotation.Nonnull; import org.opensearch.client.codegen.utils.Either; -import org.opensearch.client.codegen.utils.ObjectBuilderBase; +import org.opensearch.client.codegen.utils.builder.ObjectBuilderBase; public final class TypeParameterDiamond { @Nonnull diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java index aff4712672..aab2d65e5f 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Types.java @@ -39,12 +39,20 @@ private static Map asMap(Class clazz) { return map; } + private static Type type(String name) { + return Type.builder().withName(name).build(); + } + + private static Type type(String packageName, String name) { + return Type.builder().withPackage(packageName).withName(name).build(); + } + public static final class Primitive { - public static final Type Boolean = Type.builder().withName("boolean").build(); - public static final Type Int = Type.builder().withName("int").build(); - public static final Type Long = Type.builder().withName("long").build(); - public static final Type Float = Type.builder().withName("float").build(); - public static final Type Double = Type.builder().withName("double").build(); + public static final Type Boolean = type("boolean"); + public static final Type Int = type("int"); + public static final Type Long = type("long"); + public static final Type Float = type("float"); + public static final Type Double = type("double"); } public static final class Java { @@ -52,67 +60,65 @@ public static final class Java { public static final class Io { public static final String PACKAGE = Java.PACKAGE + ".io"; - public static final Type IOException = Type.builder().withPackage(PACKAGE).withName("IOException").build(); + public static final Type IOException = type(PACKAGE, "IOException"); } public static final class Lang { public static final String PACKAGE = Java.PACKAGE + ".lang"; - public static final Type String = Type.builder().withPackage(PACKAGE).withName("String").build(); - public static final Type Character = Type.builder().withPackage(PACKAGE).withName("Character").build(); - public static final Type Boolean = Type.builder().withPackage(PACKAGE).withName("Boolean").build(); - public static final Type Byte = Type.builder().withPackage(PACKAGE).withName("Byte").build(); - public static final Type Short = Type.builder().withPackage(PACKAGE).withName("Short").build(); - public static final Type Integer = Type.builder().withPackage(PACKAGE).withName("Integer").build(); - public static final Type Long = Type.builder().withPackage(PACKAGE).withName("Long").build(); - public static final Type Float = Type.builder().withPackage(PACKAGE).withName("Float").build(); - public static final Type Double = Type.builder().withPackage(PACKAGE).withName("Double").build(); - public static final Type Object = Type.builder().withPackage(PACKAGE).withName("Object").build(); - public static final Type Number = Type.builder().withPackage(PACKAGE).withName("Number").build(); + public static final Type String = type(PACKAGE, "String"); + public static final Type Character = type(PACKAGE, "Character"); + public static final Type Boolean = type(PACKAGE, "Boolean"); + public static final Type Byte = type(PACKAGE, "Byte"); + public static final Type Short = type(PACKAGE, "Short"); + public static final Type Integer = type(PACKAGE, "Integer"); + public static final Type Long = type(PACKAGE, "Long"); + public static final Type Float = type(PACKAGE, "Float"); + public static final Type Double = type(PACKAGE, "Double"); + public static final Type Object = type(PACKAGE, "Object"); + public static final Type Number = type(PACKAGE, "Number"); } public static final class Util { public static final String PACKAGE = Java.PACKAGE + ".util"; - public static final Type Objects = Type.builder().withPackage(PACKAGE).withName("Objects").build(); - public static final Type HashMap = Type.builder().withPackage(PACKAGE).withName("HashMap").build(); + public static final Type Objects = type(PACKAGE, "Objects"); + public static final Type HashMap = type(PACKAGE, "HashMap"); public static Type Map(Type keyType, Type valueType) { - return Map.toBuilder() - .withTypeParameters(keyType, valueType) - .withTargetShape(valueType.getTargetShape().orElse(null)) - .build(); + return Map.withTypeParameters(keyType, valueType); } - public static final Type Map = Type.builder().withPackage(PACKAGE).withName("Map").build(); + public static final Type Map = type(PACKAGE, "Map"); public static Type MapEntry(Type keyType, Type valueType) { - return Type.builder().withPackage(PACKAGE).withName("Map.Entry").withTypeParameters(keyType, valueType).build(); + return MapEntry.withTypeParameters(keyType, valueType); } + public static final Type MapEntry = type(PACKAGE, "Map.Entry"); + public static Type List(Type valueType) { - return Type.builder() - .withPackage(PACKAGE) - .withName("List") - .withTypeParameters(valueType) - .withTargetShape(valueType.getTargetShape().orElse(null)) - .build(); + return List.withTypeParameters(valueType); } + public static final Type List = type(PACKAGE, "List"); + public static final class Concurrent { public static final String PACKAGE = Util.PACKAGE + ".concurrent"; - public static final Type CompletableFuture = Type.builder().withPackage(PACKAGE).withName("CompletableFuture").build(); + public static final Type CompletableFuture = type(PACKAGE, "CompletableFuture"); } public static final class Function { public static final String PACKAGE = Util.PACKAGE + ".function"; public static Type Function(Type argType, Type returnType) { - return Type.builder().withPackage(PACKAGE).withName("Function").withTypeParameters(argType, returnType).build(); + return Function.withTypeParameters(argType, returnType); } + + public static final Type Function = type(PACKAGE, "Function"); } public static final class Stream { public static final String PACKAGE = Util.PACKAGE + ".stream"; - public static final Type Collectors = Type.builder().withPackage(PACKAGE).withName("Collectors").build(); + public static final Type Collectors = type(PACKAGE, "Collectors"); } } } @@ -122,9 +128,9 @@ public static final class Javax { public static final class Annotation { public static final String PACKAGE = Javax.PACKAGE + ".annotation"; - public static final Type Generated = Type.builder().withPackage(PACKAGE).withName("Generated").build(); - public static final Type Nonnull = Type.builder().withPackage(PACKAGE).withName("Nonnull").build(); - public static final Type Nullable = Type.builder().withPackage(PACKAGE).withName("Nullable").build(); + public static final Type Generated = type(PACKAGE, "Generated"); + public static final Type Nonnull = type(PACKAGE, "Nonnull"); + public static final Type Nullable = type(PACKAGE, "Nullable"); } } @@ -135,23 +141,21 @@ public static Type ApiClient(Type transport, Type client) { return ApiClient.withTypeParameters(transport, client); } - public static final Type ApiClient = Type.builder().withPackage(PACKAGE).withName("ApiClient").build(); + public static final Type ApiClient = type(PACKAGE, "ApiClient"); public static final class Json { public static final String PACKAGE = Client.PACKAGE + ".json"; - public static final Type JsonData = Type.builder().withPackage(PACKAGE).withName("JsonData").build(); - public static final Type JsonpDeserializable = Type.builder().withPackage(PACKAGE).withName("JsonpDeserializable").build(); - public static final Type JsonpDeserializer = Type.builder().withPackage(PACKAGE).withName("JsonpDeserializer").build(); - public static final Type JsonEnum = Type.builder().withPackage(PACKAGE).withName("JsonEnum").build(); - public static final Type JsonpMapper = Type.builder().withPackage(PACKAGE).withName("JsonpMapper").build(); - public static final Type JsonpSerializable = Type.builder().withPackage(PACKAGE).withName("JsonpSerializable").build(); - public static final Type ObjectBuilderDeserializer = Type.builder() - .withPackage(PACKAGE) - .withName("ObjectBuilderDeserializer") - .build(); - public static final Type ObjectDeserializer = Type.builder().withPackage(PACKAGE).withName("ObjectDeserializer").build(); - public static final Type PlainJsonSerializable = Type.builder().withPackage(PACKAGE).withName("PlainJsonSerializable").build(); - public static final Type UnionDeserializer = Type.builder().withPackage(PACKAGE).withName("UnionDeserializer").build(); + public static final Type JsonData = type(PACKAGE, "JsonData"); + public static final Type JsonpDeserializable = type(PACKAGE, "JsonpDeserializable"); + public static final Type JsonpDeserializer = type(PACKAGE, "JsonpDeserializer"); + public static final Type JsonEnum = type(PACKAGE, "JsonEnum"); + public static final Type JsonpMapper = type(PACKAGE, "JsonpMapper"); + public static final Type JsonpSerializable = type(PACKAGE, "JsonpSerializable"); + public static final Type ObjectBuilderDeserializer = type(PACKAGE, "ObjectBuilderDeserializer"); + public static final Type ObjectDeserializer = type(PACKAGE, "ObjectDeserializer"); + public static final Type PlainDeserializable = type(PACKAGE, "PlainDeserializable"); + public static final Type PlainJsonSerializable = type(PACKAGE, "PlainJsonSerializable"); + public static final Type UnionDeserializer = type(PACKAGE, "UnionDeserializer"); } public static final class OpenSearch { @@ -159,48 +163,57 @@ public static final class OpenSearch { public static final class _Types { public static final String PACKAGE = OpenSearch.PACKAGE + "._types"; - public static final Type ErrorResponse = Type.builder().withPackage(PACKAGE).withName("ErrorResponse").build(); - public static final Type OpenSearchException = Type.builder().withPackage(PACKAGE).withName("OpenSearchException").build(); - public static final Type RequestBase = Type.builder().withPackage(PACKAGE).withName("RequestBase").build(); - public static final Type Time = Type.builder().withPackage(PACKAGE).withName("Time").build(); + public static final Type ErrorResponse = type(PACKAGE, "ErrorResponse"); + public static final Type OpenSearchException = type(PACKAGE, "OpenSearchException"); + public static final Type RequestBase = type(PACKAGE, "RequestBase"); + public static final Type Time = type(PACKAGE, "Time"); } } public static final class Transport { public static final String PACKAGE = Client.PACKAGE + ".transport"; - public static final Type Endpoint = Type.builder().withPackage(PACKAGE).withName("Endpoint").build(); + public static final Type Endpoint = type(PACKAGE, "Endpoint"); public static Type JsonEndpoint(Type requestType, Type responseType, Type errorType) { return JsonEndpoint.withTypeParameters(requestType, responseType, errorType); } - public static final Type JsonEndpoint = Type.builder().withPackage(PACKAGE).withName("JsonEndpoint").build(); - public static final Type OpenSearchTransport = Type.builder().withPackage(PACKAGE).withName("OpenSearchTransport").build(); - public static final Type TransportOptions = Type.builder().withPackage(PACKAGE).withName("TransportOptions").build(); + public static final Type JsonEndpoint = type(PACKAGE, "JsonEndpoint"); + public static final Type OpenSearchTransport = type(PACKAGE, "OpenSearchTransport"); + public static final Type TransportOptions = type(PACKAGE, "TransportOptions"); public static final class Endpoints { public static final String PACKAGE = Transport.PACKAGE + ".endpoints"; - public static final Type SimpleEndpoint = Type.builder().withPackage(PACKAGE).withName("SimpleEndpoint").build(); + + public static final Type BooleanEndpoint = type(PACKAGE, "BooleanEndpoint"); + public static final Type BooleanResponse = type(PACKAGE, "BooleanResponse"); + + public static Type DictionaryResponse(Type keyType, Type valueType) { + return DictionaryResponse.withTypeParameters(keyType, valueType); + } + + public static final Type DictionaryResponse = type(PACKAGE, "DictionaryResponse"); + public static final Type SimpleEndpoint = type(PACKAGE, "SimpleEndpoint"); } } public static final class Util { public static final String PACKAGE = Client.PACKAGE + ".util"; - public static final Type ApiTypeHelper = Type.builder().withPackage(PACKAGE).withName("ApiTypeHelper").build(); + public static final Type ApiTypeHelper = type(PACKAGE, "ApiTypeHelper"); public static Type ObjectBuilder(Type type) { return ObjectBuilder.withTypeParameters(type); } - public static final Type ObjectBuilder = Type.builder().withPackage(PACKAGE).withName("ObjectBuilder").build(); - public static final Type ObjectBuilderBase = Type.builder().withPackage(PACKAGE).withName("ObjectBuilderBase").build(); + public static final Type ObjectBuilder = type(PACKAGE, "ObjectBuilder"); + public static final Type ObjectBuilderBase = type(PACKAGE, "ObjectBuilderBase"); public static Type TaggedUnion(Type tagType, Type baseType) { return TaggedUnion.withTypeParameters(tagType, baseType); } - public static final Type TaggedUnion = Type.builder().withPackage(PACKAGE).withName("TaggedUnion").build(); - public static final Type TaggedUnionUtils = Type.builder().withPackage(PACKAGE).withName("TaggedUnionUtils").build(); + public static final Type TaggedUnion = type(PACKAGE, "TaggedUnion"); + public static final Type TaggedUnionUtils = type(PACKAGE, "TaggedUnionUtils"); } } @@ -212,7 +225,7 @@ public static final class Json { public static final class Stream { public static final String PACKAGE = Json.PACKAGE + ".stream"; - public static final Type JsonGenerator = Type.builder().withPackage(PACKAGE).withName("JsonGenerator").build(); + public static final Type JsonGenerator = type(PACKAGE, "JsonGenerator"); } } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java index 23407f1c62..9c67463119 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/Overrides.java @@ -17,20 +17,34 @@ import javax.annotation.Nullable; import org.opensearch.client.codegen.model.Types; import org.opensearch.client.codegen.openapi.JsonPointer; -import org.opensearch.client.codegen.utils.ObjectBuilder; -import org.opensearch.client.codegen.utils.ObjectBuilderBase; +import org.opensearch.client.codegen.utils.builder.ObjectBuilder; +import org.opensearch.client.codegen.utils.builder.ObjectBuilderBase; public class Overrides { + private static final JsonPointer SCHEMAS = JsonPointer.of("components", "schemas"); + public static final Overrides OVERRIDES = builder().withSchemas( - s -> s.with( - JsonPointer.parse("/components/schemas/_common:ShardStatistics"), - b -> b.withProperties( - p -> p.with("failed", pb -> pb.withMappedType(Types.Java.Lang.Number)) - .with("skipped", pb -> pb.withMappedType(Types.Java.Lang.Number)) - .with("successful", pb -> pb.withMappedType(Types.Java.Lang.Number)) - .with("total", pb -> pb.withMappedType(Types.Java.Lang.Number)) + s -> s + // TODO: Remove this to generate property mapping types + .with(SCHEMAS.append("_common.mapping:Property"), so -> so.withShouldGenerate(ShouldGenerate.Never)) + .with(SCHEMAS.append("_common.mapping:PropertyBase"), so -> so.withShouldGenerate(ShouldGenerate.Never)) + .with(SCHEMAS.append("_common.mapping:KnnVectorProperty"), so -> so.withShouldGenerate(ShouldGenerate.Always)) + // TODO: Remove this to generate query types + .with( + SCHEMAS.append("_common.query_dsl:QueryContainer"), + so -> so.withMappedType(t -> t.withPackage(Types.Client.OpenSearch._Types.PACKAGE + ".query_dsl").withName("Query")) + ) + // TODO: Remove this to generate index settings types + .with(SCHEMAS.append("indices._common:IndexSettings"), so -> so.withShouldGenerate(ShouldGenerate.Never)) + .with( + SCHEMAS.append("_common:ShardStatistics"), + b -> b.withProperties( + p -> p.with("failed", pb -> pb.withMappedType(Types.Java.Lang.Number)) + .with("skipped", pb -> pb.withMappedType(Types.Java.Lang.Number)) + .with("successful", pb -> pb.withMappedType(Types.Java.Lang.Number)) + .with("total", pb -> pb.withMappedType(Types.Java.Lang.Number)) + ) ) - ) ).build(); @Nonnull @@ -40,6 +54,11 @@ private Overrides(Builder builder) { this.schemas = builder.schemas != null ? Collections.unmodifiableMap(builder.schemas) : Collections.emptyMap(); } + @Nonnull + public Map getSchemas() { + return schemas; + } + @Nonnull public Optional getSchema(@Nonnull JsonPointer pointer) { return Optional.ofNullable(schemas.get(pointer)); diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/PropertyOverride.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/PropertyOverride.java index c7e01d10a8..efdb28770f 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/PropertyOverride.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/PropertyOverride.java @@ -8,19 +8,27 @@ package org.opensearch.client.codegen.model.overrides; +import java.util.Objects; import java.util.Optional; +import java.util.Set; +import java.util.function.Function; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opensearch.client.codegen.model.Type; -import org.opensearch.client.codegen.utils.MapBuilderBase; -import org.opensearch.client.codegen.utils.ObjectBuilderBase; +import org.opensearch.client.codegen.utils.builder.ObjectBuilder; +import org.opensearch.client.codegen.utils.builder.ObjectBuilderBase; +import org.opensearch.client.codegen.utils.builder.ObjectMapBuilderBase; +import org.opensearch.client.codegen.utils.builder.SetBuilder; public final class PropertyOverride { @Nullable private final Type mappedType; + @Nullable + private final Set aliases; private PropertyOverride(Builder builder) { this.mappedType = builder.mappedType; + this.aliases = builder.aliases; } @Nonnull @@ -28,6 +36,11 @@ public Optional getMappedType() { return Optional.ofNullable(mappedType); } + @Nonnull + public Optional> getAliases() { + return Optional.ofNullable(aliases); + } + @Nonnull public static Builder builder() { return new Builder(); @@ -41,6 +54,8 @@ public static MapBuilder mapBuilder() { public static final class Builder extends ObjectBuilderBase { @Nullable private Type mappedType; + @Nullable + private Set aliases; private Builder() {} @@ -55,9 +70,21 @@ public Builder withMappedType(@Nullable Type mappedType) { this.mappedType = mappedType; return this; } + + @Nonnull + public Builder withAliases(@Nullable Set aliases) { + this.aliases = aliases; + return this; + } + + @Nonnull + public Builder withAliases(@Nonnull Function, ObjectBuilder>> fn) { + this.aliases = Objects.requireNonNull(fn, "fn must not be null").apply(new SetBuilder<>()).build(); + return this; + } } - public static final class MapBuilder extends MapBuilderBase { + public static final class MapBuilder extends ObjectMapBuilderBase { private MapBuilder() {} @Nonnull diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/SchemaOverride.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/SchemaOverride.java index d8359b11ff..6cc3b97006 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/SchemaOverride.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/SchemaOverride.java @@ -9,28 +9,77 @@ package org.opensearch.client.codegen.model.overrides; import java.util.Collections; +import java.util.HashSet; import java.util.Map; import java.util.Objects; import java.util.Optional; +import java.util.Set; import java.util.function.Function; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import org.opensearch.client.codegen.model.Type; import org.opensearch.client.codegen.openapi.JsonPointer; -import org.opensearch.client.codegen.utils.MapBuilderBase; -import org.opensearch.client.codegen.utils.ObjectBuilder; -import org.opensearch.client.codegen.utils.ObjectBuilderBase; +import org.opensearch.client.codegen.utils.builder.ObjectBuilder; +import org.opensearch.client.codegen.utils.builder.ObjectBuilderBase; +import org.opensearch.client.codegen.utils.builder.ObjectMapBuilderBase; public final class SchemaOverride { + @Nonnull + private final ShouldGenerate shouldGenerate; @Nonnull private final Map properties; + @Nullable + private final Function> aliasProvider; + @Nullable + private final String className; + @Nullable + private final Type mappedType; private SchemaOverride(Builder builder) { + this.shouldGenerate = builder.shouldGenerate; this.properties = builder.properties != null ? Collections.unmodifiableMap(builder.properties) : Collections.emptyMap(); + this.aliasProvider = builder.aliasProvider; + this.className = builder.className; + this.mappedType = builder.mappedType; + } + + @Nonnull + public PropertyOverride getProperty(@Nonnull String key) { + var orig = properties.get(key); + Type mappedType = null; + Set aliases = null; + if (orig != null) { + mappedType = orig.getMappedType().orElse(null); + aliases = orig.getAliases().map(HashSet::new).orElse(null); + } + + if (aliasProvider != null) { + var providerAliases = aliasProvider.apply(key); + if (providerAliases != null) { + if (aliases == null) { + aliases = new HashSet<>(providerAliases); + } else { + aliases.addAll(providerAliases); + } + } + } + + return PropertyOverride.builder().withMappedType(mappedType).withAliases(aliases).build(); } @Nonnull - public Optional getProperty(@Nonnull String key) { - return Optional.ofNullable(properties.get(key)); + public ShouldGenerate shouldGenerate() { + return shouldGenerate; + } + + @Nonnull + public Optional getClassName() { + return Optional.ofNullable(className); + } + + @Nonnull + public Optional getMappedType() { + return Optional.ofNullable(mappedType); } @Nonnull @@ -44,8 +93,16 @@ public static MapBuilder mapBuilder() { } public static final class Builder extends ObjectBuilderBase { + @Nonnull + private ShouldGenerate shouldGenerate = ShouldGenerate.IfNeeded; @Nullable private Map properties; + @Nullable + private Function> aliasProvider; + @Nullable + private String className; + @Nullable + private Type mappedType; private Builder() {} @@ -55,14 +112,44 @@ protected SchemaOverride construct() { return new SchemaOverride(this); } + @Nonnull + public Builder withShouldGenerate(@Nonnull ShouldGenerate shouldGenerate) { + this.shouldGenerate = Objects.requireNonNull(shouldGenerate, "shouldGenerate must not be null"); + return this; + } + @Nonnull public Builder withProperties(@Nonnull Function>> fn) { this.properties = Objects.requireNonNull(fn, "fn must not be null").apply(PropertyOverride.mapBuilder()).build(); return this; } + + @Nonnull + public Builder withAliasProvider(@Nullable Function> aliasProvider) { + this.aliasProvider = aliasProvider; + return this; + } + + @Nonnull + public Builder withClassName(@Nullable String className) { + this.className = className; + return this; + } + + @Nonnull + public Builder withMappedType(@Nullable Type mappedType) { + this.mappedType = mappedType; + return this; + } + + @Nonnull + public Builder withMappedType(@Nonnull Function> fn) { + this.mappedType = Objects.requireNonNull(fn, "fn must not be null").apply(Type.builder()).build(); + return this; + } } - public static final class MapBuilder extends MapBuilderBase { + public static final class MapBuilder extends ObjectMapBuilderBase { private MapBuilder() {} @Nonnull diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/ShouldGenerate.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/ShouldGenerate.java new file mode 100644 index 0000000000..068511302c --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/overrides/ShouldGenerate.java @@ -0,0 +1,15 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.codegen.model.overrides; + +public enum ShouldGenerate { + Always, + IfNeeded, + Never +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiDiscriminator.java b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiDiscriminator.java new file mode 100644 index 0000000000..2cf855dbb4 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiDiscriminator.java @@ -0,0 +1,29 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.codegen.openapi; + +import io.swagger.v3.oas.models.media.Discriminator; +import java.util.Optional; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class OpenApiDiscriminator extends OpenApiElement { + @Nullable + private final String propertyName; + + protected OpenApiDiscriminator(@Nullable OpenApiElement parent, @Nonnull JsonPointer pointer, @Nonnull Discriminator discriminator) { + super(parent, pointer); + this.propertyName = discriminator.getPropertyName(); + } + + @Nonnull + public Optional getPropertyName() { + return Optional.ofNullable(propertyName); + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java index 8a1a3d1d03..79ca01555f 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSchema.java @@ -22,9 +22,9 @@ import javax.annotation.Nullable; import org.opensearch.client.codegen.utils.Lists; import org.opensearch.client.codegen.utils.Maps; -import org.opensearch.client.codegen.utils.ObjectBuilderBase; import org.opensearch.client.codegen.utils.Sets; import org.opensearch.client.codegen.utils.Versions; +import org.opensearch.client.codegen.utils.builder.ObjectBuilderBase; import org.semver4j.Semver; public class OpenApiSchema extends OpenApiRefElement { @@ -66,6 +66,10 @@ public class OpenApiSchema extends OpenApiRefElement { @Nullable private final String pattern; @Nullable + private final OpenApiDiscriminator discriminator; + @Nullable + private final Object constValue; + @Nullable private final Semver versionRemoved; @Nullable private final Semver versionDeprecated; @@ -87,6 +91,8 @@ private OpenApiSchema(@Nonnull Builder builder) { required = builder.required; title = builder.title; pattern = builder.pattern; + discriminator = builder.discriminator; + constValue = builder.constValue; versionRemoved = builder.versionRemoved; versionDeprecated = builder.versionDeprecated; } @@ -98,7 +104,10 @@ protected OpenApiSchema(@Nullable OpenApiElement parent, @Nonnull JsonPointer var key = pointer.getLastKey().orElseThrow(); var colonIdx = key.indexOf(':'); if (colonIdx >= 0) { - namespace = key.substring(0, colonIdx).replaceAll("\\._common", "").replaceAll("^_common", "_types"); + namespace = key.substring(0, colonIdx) + .replaceAll("\\._common", "") + .replaceAll("^_common", "_types") + .replaceAll("^_core", "core"); name = key.substring(colonIdx + 1); } else { namespace = null; @@ -136,6 +145,10 @@ protected OpenApiSchema(@Nullable OpenApiElement parent, @Nonnull JsonPointer pattern = schema.getPattern(); + discriminator = child("discriminator", schema.getDiscriminator(), OpenApiDiscriminator::new); + + constValue = schema.getConst(); + var extensions = schema.getExtensions(); versionRemoved = Maps.tryGet(extensions, "x-version-removed").map(v -> Versions.coerce((String) v)).orElse(null); @@ -196,10 +209,6 @@ public boolean isString() { return is(OpenApiSchemaType.String); } - public boolean isStringEnum() { - return isString() && hasEnums(); - } - public boolean hasAllOf() { return allOf != null && !allOf.isEmpty(); } @@ -256,6 +265,10 @@ public Optional> getRequired() { return Sets.unmodifiableOpt(required); } + public boolean hasTitle() { + return title != null; + } + @Nonnull public Optional getTitle() { return Optional.ofNullable(title); @@ -266,6 +279,20 @@ public Optional getPattern() { return Optional.ofNullable(pattern); } + @Nonnull + public Optional getDiscriminator() { + return Optional.ofNullable(discriminator); + } + + public boolean hasConst() { + return constValue != null; + } + + @Nonnull + public Optional getConst() { + return Optional.ofNullable(constValue); + } + @Nonnull public Optional getVersionRemoved() { return Optional.ofNullable(versionRemoved); @@ -355,6 +382,10 @@ public static class Builder extends ObjectBuilderBase { @Nullable private String pattern; @Nullable + private OpenApiDiscriminator discriminator; + @Nullable + private Object constValue; + @Nullable private Semver versionRemoved; @Nullable private Semver versionDeprecated; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSpecification.java b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSpecification.java index aa09da8d06..ffdf3f7741 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSpecification.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiSpecification.java @@ -84,7 +84,7 @@ > void addElement(@Nonnull JsonPointer pointer, @Non } @Nonnull - > T getElement(@Nonnull JsonPointer pointer, @Nonnull Class type) { + public > T getElement(@Nonnull JsonPointer pointer, @Nonnull Class type) { Objects.requireNonNull(pointer, "pointer must not be null"); Objects.requireNonNull(type, "type must not be null"); return Optional.ofNullable(elementCache.get(type)) diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/JavaCodeFormatter.java b/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/JavaCodeFormatter.java index 8f2717a120..08273b2947 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/JavaCodeFormatter.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/JavaCodeFormatter.java @@ -25,7 +25,7 @@ import javax.annotation.Nonnull; import org.opensearch.client.codegen.exceptions.JavaFormatterException; import org.opensearch.client.codegen.utils.MavenArtifactResolver; -import org.opensearch.client.codegen.utils.ObjectBuilderBase; +import org.opensearch.client.codegen.utils.builder.ObjectBuilderBase; public class JavaCodeFormatter implements AutoCloseable { private final Formatter formatter; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateGlobalContext.java b/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateGlobalContext.java index 2208392b1c..236a6d1623 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateGlobalContext.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateGlobalContext.java @@ -17,8 +17,9 @@ import org.apache.commons.text.StringEscapeUtils; import org.opensearch.client.codegen.model.Types; import org.opensearch.client.codegen.renderer.lambdas.TemplateStringLambda; -import org.opensearch.client.codegen.utils.ObjectBuilderBase; +import org.opensearch.client.codegen.utils.NameSanitizer; import org.opensearch.client.codegen.utils.Strings; +import org.opensearch.client.codegen.utils.builder.ObjectBuilderBase; public final class TemplateGlobalContext implements Mustache.CustomContext { @Nonnull @@ -47,6 +48,7 @@ public static Builder builder() { return new Builder().withLambda("quoted", s -> '\"' + StringEscapeUtils.escapeJava(s) + '\"') .withLambda("camelCase", Strings::toCamelCase) .withLambda("pascalCase", Strings::toPascalCase) + .withLambda("asFieldName", NameSanitizer::wireNameToField) .withLambda("toLower", s -> s.toLowerCase()) .withLambda("ERROR", s -> { throw new RuntimeException(s); diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateLoader.java b/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateLoader.java index 6a6583125b..8fb20e5dec 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateLoader.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateLoader.java @@ -17,8 +17,8 @@ import java.util.concurrent.ConcurrentHashMap; import javax.annotation.Nonnull; import org.apache.commons.io.IOUtils; -import org.opensearch.client.codegen.utils.ObjectBuilderBase; import org.opensearch.client.codegen.utils.Strings; +import org.opensearch.client.codegen.utils.builder.ObjectBuilderBase; public final class TemplateLoader implements Mustache.TemplateLoader { private static final ConcurrentHashMap CACHE = new ConcurrentHashMap<>(); diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateRenderer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateRenderer.java index 32daa020c2..e5b5b5d1c8 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateRenderer.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateRenderer.java @@ -23,7 +23,7 @@ import org.opensearch.client.codegen.exceptions.JavaFormatterException; import org.opensearch.client.codegen.exceptions.RenderException; import org.opensearch.client.codegen.model.Shape; -import org.opensearch.client.codegen.utils.ObjectBuilderBase; +import org.opensearch.client.codegen.utils.builder.ObjectBuilderBase; public final class TemplateRenderer { @Nonnull @@ -47,7 +47,8 @@ private TemplateRenderer(@Nonnull Builder builder) { public void render(String templateName, Object context, Writer out) throws RenderException { try { - templateCache.computeIfAbsent(templateName, compiler::loadTemplate).execute(context, this.context, out); + var template = templateCache.computeIfAbsent(templateName, compiler::loadTemplate); + template.execute(context, this.context, out); } catch (MustacheException e) { throw new RenderException("Failed to render: " + context, e); } @@ -60,7 +61,7 @@ public String render(String templateName, Object context) throws RenderException } public void renderJava(Shape shape, File outputFile) throws RenderException { - var classBody = render(shape.getClass().getSimpleName(), shape); + var classBody = render(shape.getTemplateName(), shape); var classHeader = render("Partials/ClassHeader", shape); try (Writer fileWriter = new FileWriter(outputFile)) { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateValueFormatter.java b/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateValueFormatter.java index fa71560173..714620ec4a 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateValueFormatter.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/renderer/TemplateValueFormatter.java @@ -13,7 +13,7 @@ import java.util.Map; import java.util.Objects; import javax.annotation.Nonnull; -import org.opensearch.client.codegen.utils.ObjectBuilderBase; +import org.opensearch.client.codegen.utils.builder.ObjectBuilderBase; public final class TemplateValueFormatter implements Mustache.Formatter { @Nonnull diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/JavaClassKind.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/JavaClassKind.java index 2e587790c2..76bdc1d5a4 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/JavaClassKind.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/JavaClassKind.java @@ -13,7 +13,8 @@ public enum JavaClassKind { Class, - Enum; + Enum, + Interface; private static final Map VALUES = Maps.createLookupOf(values(), JavaClassKind::toString); diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/MapBuilderBase.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/MapBuilderBase.java deleted file mode 100644 index 221d434d16..0000000000 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/MapBuilderBase.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -package org.opensearch.client.codegen.utils; - -import java.util.Collections; -import java.util.Map; -import java.util.Objects; -import java.util.function.Function; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class MapBuilderBase, Self extends MapBuilderBase> extends - ObjectBuilderBase, Self> { - @Nullable - private Map map; - - protected MapBuilderBase() {} - - protected abstract @Nonnull VBuilder valueBuilder(); - - @Override - protected @Nonnull Map construct() { - return map != null ? Collections.unmodifiableMap(map) : Collections.emptyMap(); - } - - public @Nonnull Self with(@Nonnull Map map) { - this.map = _mapPutAll(this.map, map); - return self(); - } - - public @Nonnull Self with(@Nonnull K key, @Nonnull V value) { - this.map = _mapPut(this.map, key, value); - return self(); - } - - public @Nonnull Self with(@Nonnull K key, @Nonnull Function> fn) { - return with(key, Objects.requireNonNull(fn, "fn must not be null").apply(valueBuilder()).build()); - } -} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Markdown.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Markdown.java new file mode 100644 index 0000000000..c8476f465b --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Markdown.java @@ -0,0 +1,25 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.codegen.utils; + +import javax.annotation.Nonnull; +import org.commonmark.parser.Parser; +import org.commonmark.renderer.html.HtmlRenderer; + +public final class Markdown { + private Markdown() {} + + private static final Parser PARSER = Parser.builder().build(); + private static final HtmlRenderer RENDERER = HtmlRenderer.builder().omitSingleParagraphP(true).build(); + + @Nonnull + public static String toJavaDocHtml(@Nonnull String markdown) { + return RENDERER.render(PARSER.parse(markdown)).strip(); + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/NameSanitizer.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/NameSanitizer.java similarity index 63% rename from java-codegen/src/main/java/org/opensearch/client/codegen/NameSanitizer.java rename to java-codegen/src/main/java/org/opensearch/client/codegen/utils/NameSanitizer.java index 8370a06c14..badf2dd36e 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/NameSanitizer.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/NameSanitizer.java @@ -6,21 +6,25 @@ * compatible open source license. */ -package org.opensearch.client.codegen; +package org.opensearch.client.codegen.utils; -import java.util.HashSet; import java.util.Set; import javax.annotation.Nonnull; -import org.opensearch.client.codegen.utils.Strings; public class NameSanitizer { - private static final Set reservedWords = new HashSet<>() { - { - add("default"); - add("native"); - add("transient"); - } - }; + private static final Set reservedWords = Set.of( + "default", + "native", + "transient", + "boolean", + "char", + "byte", + "short", + "int", + "long", + "float", + "double" + ); @Nonnull public static String wireNameToField(@Nonnull String wireName) { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/ObjectBuilderBase.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/ObjectBuilderBase.java deleted file mode 100644 index 8e71c9da70..0000000000 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/ObjectBuilderBase.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.client.codegen.utils; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import javax.annotation.Nonnull; - -public abstract class ObjectBuilderBase> implements ObjectBuilder { - private boolean _used = false; - - protected ObjectBuilderBase() {} - - protected @Nonnull Self self() { - // noinspection unchecked - return (Self) this; - } - - protected abstract @Nonnull T construct(); - - protected final void _ensureSingleUse() { - if (this._used) { - throw new IllegalStateException("Object builders can only be used once"); - } - this._used = true; - } - - @Override - public final @Nonnull T build() { - var self = self(); - self._ensureSingleUse(); - return self.construct(); - } - - // ----- Map utilities - - private static final class OwnedMap extends HashMap { - OwnedMap() {} - - OwnedMap(Map m) { - super(m); - } - } - - private static Map _mutableMap(Map map) { - if (map == null) { - return new OwnedMap<>(); - } else if (map instanceof ObjectBuilderBase.OwnedMap) { - return map; - } else { - // Adding to a map we don't own: make a defensive copy, also ensuring it is mutable. - return new OwnedMap<>(map); - } - } - - protected static Map _mapPut(Map map, K key, V value) { - map = _mutableMap(map); - map.put(key, value); - return map; - } - - protected static Map _mapPutAll(Map map, Map entries) { - if (map == null) { - // Keep the original map to avoid an unnecessary copy. - // It will be copied if we add more entries. - return Objects.requireNonNull(entries); - } else { - map = _mutableMap(map); - map.putAll(entries); - return map; - } - } -} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Strings.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Strings.java index d6a751a84f..4f74c68671 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Strings.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/Strings.java @@ -8,10 +8,13 @@ package org.opensearch.client.codegen.utils; +import java.util.Collection; import java.util.HashMap; import java.util.Locale; import java.util.Map; import java.util.Objects; +import java.util.function.Function; +import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.apache.commons.text.CaseUtils; @@ -73,4 +76,13 @@ public static String toCamelCase(@Nonnull String str) { public static String toPascalCase(@Nonnull String str) { return toCamelCase(str, true); } + + @Nonnull + public static String join(@Nonnull Collection items, @Nonnull String delimiter, @Nonnull Function mapper) { + Objects.requireNonNull(items, "items must not be null"); + Objects.requireNonNull(delimiter, "delimiter must not be null"); + Objects.requireNonNull(mapper, "mapper must not be null"); + + return items.stream().map(mapper).collect(Collectors.joining(delimiter)); + } } diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ListBuilder.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ListBuilder.java new file mode 100644 index 0000000000..d4f8ce3098 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ListBuilder.java @@ -0,0 +1,13 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.codegen.utils.builder; + +public final class ListBuilder extends ListBuilderBase> { + public ListBuilder() {} +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ListBuilderBase.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ListBuilderBase.java new file mode 100644 index 0000000000..eee8b04880 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ListBuilderBase.java @@ -0,0 +1,36 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.codegen.utils.builder; + +import java.util.List; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public abstract class ListBuilderBase> extends ObjectBuilderBase, Builder> { + @Nullable + private List list; + + protected ListBuilderBase() {} + + @Override + protected final @Nonnull List construct() { + return _mutableList(list); + } + + public final @Nonnull Builder with(@Nonnull List list) { + this.list = _listAddAll(this.list, list); + return self(); + } + + @SafeVarargs + public final @Nonnull Builder with(@Nonnull V value, @Nonnull V... values) { + this.list = _listAdd(this.list, value, values); + return self(); + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/MapBuilder.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/MapBuilder.java new file mode 100644 index 0000000000..4889f780a8 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/MapBuilder.java @@ -0,0 +1,13 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.codegen.utils.builder; + +public final class MapBuilder extends MapBuilderBase> { + public MapBuilder() {} +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/MapBuilderBase.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/MapBuilderBase.java new file mode 100644 index 0000000000..8208b9a4f4 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/MapBuilderBase.java @@ -0,0 +1,35 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.codegen.utils.builder; + +import java.util.Map; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public abstract class MapBuilderBase> extends ObjectBuilderBase, Builder> { + @Nullable + private Map map; + + protected MapBuilderBase() {} + + @Override + protected final @Nonnull Map construct() { + return _mutableMap(map); + } + + public final @Nonnull Builder with(@Nonnull Map map) { + this.map = _mapPutAll(this.map, map); + return self(); + } + + public final @Nonnull Builder with(@Nonnull K key, @Nonnull V value) { + this.map = _mapPut(this.map, key, value); + return self(); + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/ObjectBuilder.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ObjectBuilder.java similarity index 85% rename from java-codegen/src/main/java/org/opensearch/client/codegen/utils/ObjectBuilder.java rename to java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ObjectBuilder.java index 3414747040..ece3e9a90c 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/ObjectBuilder.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ObjectBuilder.java @@ -6,7 +6,7 @@ * compatible open source license. */ -package org.opensearch.client.codegen.utils; +package org.opensearch.client.codegen.utils.builder; import javax.annotation.Nonnull; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ObjectBuilderBase.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ObjectBuilderBase.java new file mode 100644 index 0000000000..efcf93779f --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ObjectBuilderBase.java @@ -0,0 +1,209 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +package org.opensearch.client.codegen.utils.builder; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.function.BiFunction; +import java.util.function.Function; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public abstract class ObjectBuilderBase> implements ObjectBuilder { + private boolean _used = false; + + protected ObjectBuilderBase() {} + + protected @Nonnull Builder self() { + // noinspection unchecked + return (Builder) this; + } + + protected abstract @Nonnull T construct(); + + protected final void _ensureSingleUse() { + if (this._used) { + throw new IllegalStateException("Object builders can only be used once"); + } + this._used = true; + } + + @Override + public final @Nonnull T build() { + var self = self(); + self._ensureSingleUse(); + return self.construct(); + } + + // ----- Conditional utilities + + public final @Nonnull Builder when(boolean condition, @Nonnull Function fn) { + return condition ? Objects.requireNonNull(fn, "fn must not be null").apply(self()) : self(); + } + + public final @Nonnull Builder whenNonNull(@Nullable V value, @Nonnull BiFunction fn) { + return value != null ? Objects.requireNonNull(fn, "fn must not be null").apply(self(), value) : self(); + } + + // ----- Set utilities + + private static final class OwnedSet extends HashSet { + OwnedSet() {} + + OwnedSet(Collection c) { + super(c); + } + }; + + protected static Set _mutableSet(Set set) { + if (set == null) { + return new OwnedSet<>(); + } else if (set instanceof OwnedSet) { + return set; + } else { + // Adding to a set we don't own: make a defensive copy, also ensuring it is mutable. + return new OwnedSet<>(set); + } + } + + @SafeVarargs + protected static Set _setAdd(Set set, T value, T... values) { + set = _mutableSet(set); + set.add(value); + if (values.length > 0) { + set.addAll(Arrays.asList(values)); + } + return set; + } + + protected static Set _setAddAll(Set set, Set values) { + if (set == null) { + // Keep the original set to avoid an unnecessary copy. + // It will be copied if we add more values. + return Objects.requireNonNull(values); + } else { + set = _mutableSet(set); + set.addAll(values); + return set; + } + } + + // ----- List utilities + + private static final class OwnedList extends ArrayList { + OwnedList() {} + + OwnedList(Collection c) { + super(c); + } + }; + + protected static List _mutableList(List list) { + if (list == null) { + return new OwnedList<>(); + } else if (list instanceof OwnedList) { + return list; + } else { + // Adding to a list we don't own: make a defensive copy, also ensuring it is mutable. + return new OwnedList<>(list); + } + } + + @SafeVarargs + protected static List _listAdd(List list, T value, T... values) { + list = _mutableList(list); + list.add(value); + if (values.length > 0) { + list.addAll(Arrays.asList(values)); + } + return list; + } + + protected static List _listAddAll(List list, List values) { + if (list == null) { + // Keep the original list to avoid an unnecessary copy. + // It will be copied if we add more values. + return Objects.requireNonNull(values); + } else { + list = _mutableList(list); + list.addAll(values); + return list; + } + } + + // ----- Map utilities + + private static final class OwnedMap extends HashMap { + OwnedMap() {} + + OwnedMap(Map m) { + super(m); + } + } + + protected static Map _mutableMap(Map map) { + if (map == null) { + return new OwnedMap<>(); + } else if (map instanceof OwnedMap) { + return map; + } else { + // Adding to a map we don't own: make a defensive copy, also ensuring it is mutable. + return new OwnedMap<>(map); + } + } + + protected static Map _mapPut(Map map, K key, V value) { + map = _mutableMap(map); + map.put(key, value); + return map; + } + + protected static Map _mapPutAll(Map map, Map entries) { + if (map == null) { + // Keep the original map to avoid an unnecessary copy. + // It will be copied if we add more entries. + return Objects.requireNonNull(entries); + } else { + map = _mutableMap(map); + map.putAll(entries); + return map; + } + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ObjectListBuilderBase.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ObjectListBuilderBase.java new file mode 100644 index 0000000000..482295c411 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ObjectListBuilderBase.java @@ -0,0 +1,26 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.codegen.utils.builder; + +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Nonnull; + +public abstract class ObjectListBuilderBase< + V, + VBuilder extends ObjectBuilder, + Builder extends ObjectListBuilderBase> extends ListBuilderBase { + protected ObjectListBuilderBase() {} + + protected abstract @Nonnull VBuilder valueBuilder(); + + public final @Nonnull Builder with(@Nonnull Function> fn) { + return with(Objects.requireNonNull(fn, "fn must not be null").apply(valueBuilder()).build()); + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ObjectMapBuilderBase.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ObjectMapBuilderBase.java new file mode 100644 index 0000000000..7ea407f75e --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ObjectMapBuilderBase.java @@ -0,0 +1,27 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.codegen.utils.builder; + +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Nonnull; + +public abstract class ObjectMapBuilderBase< + K, + V, + VBuilder extends ObjectBuilder, + Builder extends ObjectMapBuilderBase> extends MapBuilderBase { + protected ObjectMapBuilderBase() {} + + protected abstract @Nonnull VBuilder valueBuilder(); + + public final @Nonnull Builder with(@Nonnull K key, @Nonnull Function> fn) { + return with(key, Objects.requireNonNull(fn, "fn must not be null").apply(valueBuilder()).build()); + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ObjectSetBuilderBase.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ObjectSetBuilderBase.java new file mode 100644 index 0000000000..5cb8623a1e --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/ObjectSetBuilderBase.java @@ -0,0 +1,24 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.codegen.utils.builder; + +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Nonnull; + +public abstract class ObjectSetBuilderBase, Builder extends ObjectSetBuilderBase> + extends SetBuilderBase { + protected ObjectSetBuilderBase() {} + + protected abstract @Nonnull VBuilder valueBuilder(); + + public final @Nonnull Builder with(@Nonnull Function> fn) { + return with(Objects.requireNonNull(fn, "fn must not be null").apply(valueBuilder()).build()); + } +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/SetBuilder.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/SetBuilder.java new file mode 100644 index 0000000000..3841dfcfdd --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/SetBuilder.java @@ -0,0 +1,13 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.codegen.utils.builder; + +public final class SetBuilder extends SetBuilderBase> { + public SetBuilder() {} +} diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/SetBuilderBase.java b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/SetBuilderBase.java new file mode 100644 index 0000000000..4696d96ae9 --- /dev/null +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/utils/builder/SetBuilderBase.java @@ -0,0 +1,36 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.client.codegen.utils.builder; + +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public abstract class SetBuilderBase> extends ObjectBuilderBase, Builder> { + @Nullable + private Set set; + + protected SetBuilderBase() {} + + @Override + protected final @Nonnull Set construct() { + return _mutableSet(set); + } + + public final @Nonnull Builder with(@Nonnull Set set) { + this.set = _setAddAll(this.set, set); + return self(); + } + + @SafeVarargs + public final @Nonnull Builder with(@Nonnull V value, @Nonnull V... values) { + this.set = _setAdd(this.set, value, values); + return self(); + } +} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/DictionaryResponseShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/DictionaryResponseShape.mustache new file mode 100644 index 0000000000..b04a2eb119 --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/DictionaryResponseShape.mustache @@ -0,0 +1,32 @@ +{{>Partials/ClassDeclaration}} { + // --------------------------------------------------------------------------------------------- + + {{>ObjectShape/Constructor}} + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link {{className}}}. + */ + public static class Builder extends {{extendsType.name}}.AbstractBuilder<{{keyType}}, {{valueType}}, Builder> + implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> { + {{>ObjectShape/Builder/SelfImpl}} + + /** + * Builds a {@link {{className}}}. + * + * @throws NullPointerException if some of the required fields are null. + */ + public {{className}} build() { + _checkSingleUse(); + super.tKeySerializer(null); + super.tValueSerializer(null); + + return new {{className}}(this); + } + } + + // --------------------------------------------------------------------------------------------- + + {{>ObjectShape/Deserialize}} +} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache index a9a14284f0..543bfdb110 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/EnumShape.mustache @@ -3,19 +3,36 @@ {{^-first}} {{/-first}} +{{#description}} + /** + * {{.}} + */ +{{/description}} {{#deprecated}} @Deprecated {{/deprecated}} - {{name}}({{#quoted}}{{wireName}}{{/quoted}}){{#-last}};{{/-last}}{{^-last}},{{/-last}} + {{name}}({{#quoted}}{{wireName}}{{/quoted}}{{#aliases}}, {{#quoted}}{{.}}{{/quoted}}{{/aliases}}){{#-last}};{{/-last}}{{^-last}},{{/-last}} {{/variants}} private final String jsonValue; +{{#anyHasAliases}} + private final String[] aliases; +{{/anyHasAliases}} - {{className}}(String jsonValue) { + {{className}}(String jsonValue{{#anyHasAliases}}, String... aliases{{/anyHasAliases}}) { this.jsonValue = jsonValue; +{{#anyHasAliases}} + this.aliases = aliases; +{{/anyHasAliases}} } public String jsonValue() { return this.jsonValue; } +{{#anyHasAliases}} + + public String[] aliases() { + return this.aliases; + } +{{/anyHasAliases}} public static final JsonEnum.Deserializer<{{className}}> _DESERIALIZER = new JsonEnum.Deserializer<>({{className}}.values()); } \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache index 0cd936e3b4..25bf01d350 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache @@ -4,7 +4,16 @@ // --------------------------------------------------------------------------------------------- {{>ObjectShape/Constructor}} - +{{#referencingDiscriminatedUnions}} + + /** + * {@link {{union.className}}} variant kind. + */ + @Override + public {{union.type}}.Kind _{{#camelCase}}{{union.className}}{{/camelCase}}Kind() { + return {{union.type}}.Kind.{{#pascalCase}}{{discriminatorValue}}{{/pascalCase}}; + } +{{/referencingDiscriminatedUnions}} {{>ObjectShape/Getters}} {{#hasFieldsToSerialize}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache index b3ab0f1355..f715bd75d5 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder.mustache @@ -4,18 +4,19 @@ */ {{#extendsOtherShape}} public static class Builder extends {{extendsType}}.AbstractBuilder - implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> { - {{>ObjectShape/Builder/SelfImpl}} - + implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> {{#shouldImplementPlainDeserializable}}, {{TYPES.Client.Json.PlainDeserializable}}{{/shouldImplementPlainDeserializable}} { {{>ObjectShape/Builder/Fields}} + {{>ObjectShape/Builder/SelfImpl}} + {{>ObjectShape/Builder/BuildImpl}} } {{/extendsOtherShape}} {{^extendsOtherShape}} {{#extendedByOtherShape}} public static class Builder extends {{type}}.AbstractBuilder - implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> { + implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}>{{#shouldImplementPlainDeserializable}}, {{TYPES.Client.Json.PlainDeserializable}}{{/shouldImplementPlainDeserializable}} + { {{>ObjectShape/Builder/SelfImpl}} {{>ObjectShape/Builder/BuildImpl}} @@ -23,7 +24,12 @@ {{/extendedByOtherShape}} {{^extendedByOtherShape}} public static class Builder extends {{TYPES.Client.Util.ObjectBuilderBase}} - implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> { + implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}>{{#shouldImplementPlainDeserializable}}, {{TYPES.Client.Json.PlainDeserializable}}{{/shouldImplementPlainDeserializable}} + { + {{#shouldImplementPlainDeserializable}} + {{>ObjectShape/Builder/SelfImpl}} + + {{/shouldImplementPlainDeserializable}} {{>ObjectShape/Builder/Fields}} {{>ObjectShape/Builder/BuildImpl}} @@ -35,7 +41,9 @@ protected abstract static class AbstractBuilder> extends {{#extendsOtherShape}}{{extendsType}}.AbstractBuilder{{/extendsOtherShape}}{{^extendsOtherShape}}{{TYPES.Client.Util.ObjectBuilderBase}}{{/extendsOtherShape}} { {{>ObjectShape/Builder/Fields}} + {{^extendsOtherShape}} protected abstract BuilderT self(); + {{/extendsOtherShape}} } {{/extendedByOtherShape}} \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/SelfImpl.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/SelfImpl.mustache index 7d897fe252..ce3c4f49ed 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/SelfImpl.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Builder/SelfImpl.mustache @@ -1,4 +1,4 @@ @Override -protected Builder self() { +{{#shouldImplementPlainDeserializable}}public{{/shouldImplementPlainDeserializable}}{{^shouldImplementPlainDeserializable}}protected{{/shouldImplementPlainDeserializable}} Builder self() { return this; } \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache index 4496a97a93..4d37bb6a2f 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Deserialize.mustache @@ -12,10 +12,10 @@ protected static > void setup{{className}}Deserializer({{TYPES.Client.Json.ObjectDeserializer}} op) { {{/extendedByOtherShape}} {{#extendsOtherShape}} - {{extendsType}}.setup{{extendsType.name}}Deserializer(op); + setup{{extendsType.name}}Deserializer(op{{#extendsType.typeParams}}, {{>Type/deserializer}}{{/extendsType.typeParams}}); {{/extendsOtherShape}} {{#bodyFields}} - op.add({{#extendedByOtherShape}}Abstract{{/extendedByOtherShape}}Builder::{{name}}, {{#type}}{{>Type/deserializer}}{{/type}}, {{#quoted}}{{wireName}}{{/quoted}}); + op.add({{#extendedByOtherShape}}Abstract{{/extendedByOtherShape}}Builder::{{name}}, {{#type}}{{>Type/deserializer}}{{/type}}, {{#quoted}}{{wireName}}{{/quoted}}{{#aliases}}, {{#quoted}}{{.}}{{/quoted}}{{/aliases}}); {{/bodyFields}} {{#additionalPropertiesField}} op.setUnknownFieldHandler((builder, name, parser, mapper) -> { @@ -25,4 +25,12 @@ builder.{{name}}.put(name, {{#type.mapValueType}}{{>Type/deserializer}}{{/type.mapValueType}}.deserialize(parser, mapper)); }); {{/additionalPropertiesField}} + {{#distinctDiscriminatorFieldValues}} + + op.ignore({{#quoted}}{{key}}{{/quoted}}); + {{/distinctDiscriminatorFieldValues}} + {{#shortcutProperty}} + + op.shortcutProperty({{#quoted}}{{.}}{{/quoted}}); + {{/shortcutProperty}} } \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Equals.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Equals.mustache index 1670834380..62d50543d5 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Equals.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Equals.mustache @@ -1,3 +1,4 @@ + @Override public boolean equals(Object o) { {{#extendsOtherShape}} if(!super.equals(o)) { @@ -6,27 +7,28 @@ {{/extendsOtherShape}} if(this == o) return true; if(o == null || this.getClass() != o.getClass()) return false; - {{^hasFields}} - return true; - {{/hasFields}} - {{#hasFields}} + {{#fields}} + {{#-first}} {{className}} other = ({{className}})o; return - {{#fields}} - {{#required}} - {{#type.isPrimitive}} - this.{{name}} == other.{{name}} - {{/type.isPrimitive}} - {{^type.isPrimitive}} - this.{{name}}.equals(other.{{name}}) - {{/type.isPrimitive}} - {{/required}} - {{^required}} - {{TYPES.Java.Util.Objects}}.equals(this.{{name}}, other.{{name}}) - {{/required}} - {{^-last}} - && - {{/-last}} - {{/fields}}; - {{/hasFields}} + {{/-first}} + {{^-first}} + && + {{/-first}} + {{#required}} + {{#type.isPrimitive}} + this.{{name}} == other.{{name}} + {{/type.isPrimitive}} + {{^type.isPrimitive}} + this.{{name}}.equals(other.{{name}}) + {{/type.isPrimitive}} + {{/required}} + {{^required}} + {{TYPES.Java.Util.Objects}}.equals(this.{{name}}, other.{{name}}) + {{/required}} + {{/fields}} + {{^fields}} + return true + {{/fields}} + ; } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/HashCode.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/HashCode.mustache index d14479eb81..354fd87e80 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/HashCode.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/HashCode.mustache @@ -1,3 +1,4 @@ + @Override public int hashCode() { {{#extendsOtherShape}} int result = super.hashCode(); diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache index e40f75049e..130c94bcec 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache @@ -11,6 +11,9 @@ {{/extendsOtherShape}} protected void serializeInternal({{TYPES.Jakarta.Json.Stream.JsonGenerator}} generator, {{TYPES.Client.Json.JsonpMapper}} mapper) { +{{#distinctDiscriminatorFieldValues}} + generator.write({{#quoted}}{{key}}{{/quoted}}, {{#quoted}}{{value}}{{/quoted}}); +{{/distinctDiscriminatorFieldValues}} {{#extendsOtherShape}} super.serializeInternal(generator, mapper); {{/extendsOtherShape}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache index f73f6dd4a2..f73e867c2f 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache @@ -35,7 +35,7 @@ /** * Endpoint "{@code {{operationGroup}}}". */ - public static final {{TYPES.Client.Transport.Endpoint}}<{{className}}, {{responseType}}, {{TYPES.Client.OpenSearch._Types.ErrorResponse}}> _ENDPOINT = new {{TYPES.Client.Transport.Endpoints.SimpleEndpoint}}<>( + public static final {{TYPES.Client.Transport.Endpoint}}<{{className}}, {{responseType}}, {{TYPES.Client.OpenSearch._Types.ErrorResponse}}> _ENDPOINT = new {{#isBooleanRequest}}{{TYPES.Client.Transport.Endpoints.BooleanEndpoint}}{{/isBooleanRequest}}{{^isBooleanRequest}}{{TYPES.Client.Transport.Endpoints.SimpleEndpoint}}{{/isBooleanRequest}}<>( // Request method request -> {{#quoted}}{{httpMethod}}{{/quoted}}, // Request path @@ -92,9 +92,12 @@ {{^hasQueryParams}} {{TYPES.Client.Transport.Endpoints.SimpleEndpoint}}.emptyMap(), {{/hasQueryParams}} - {{TYPES.Client.Transport.Endpoints.SimpleEndpoint}}.emptyMap(), + {{TYPES.Client.Transport.Endpoints.SimpleEndpoint}}.emptyMap() + {{^isBooleanRequest}} + , {{hasRequestBody}}, {{responseType}}._DESERIALIZER + {{/isBooleanRequest}} ); {{>ObjectShape/HashCode}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache index 8a584d6812..21c3a05a47 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape.mustache @@ -1,10 +1,26 @@ {{>Partials/ClassDeclaration}} { - public enum Kind { - {{#variants}}{{#pascalCase}}{{name}}{{/pascalCase}}{{^-last}},{{/-last}}{{/variants}} + /** + * {@link {{className}}} variant kinds. + */ + public enum Kind{{#discriminated}} implements {{TYPES.Client.Json.JsonEnum}}{{/discriminated}} { + {{#variants}}{{#pascalCase}}{{name}}{{/pascalCase}}{{#discriminated}}({{#quoted}}{{name}}{{/quoted}}){{/discriminated}}{{^-last}},{{/-last}}{{/variants}} + {{#discriminated}}; + + private final String jsonValue; + + Kind(String jsonValue) { + this.jsonValue = jsonValue; + } + + @Override + public String jsonValue() { + return jsonValue; + } + {{/discriminated}} } private final Kind _kind; - private final Object _value; + private final {{variantBaseType}} _value; @Override public final Kind _kind() { @@ -12,14 +28,22 @@ } @Override - public final Object _get() { + public final {{variantBaseType}} _get() { return _value; } +{{#discriminated}} + public {{className}}({{variantBaseType}} value) { + this._kind = {{TYPES.Client.Util.ApiTypeHelper}}.requireNonNull(value._{{#camelCase}}{{className}}{{/camelCase}}Kind(), this, ""); + this._value = {{TYPES.Client.Util.ApiTypeHelper}}.requireNonNull(value, this, ""); + } +{{/discriminated}} +{{^discriminated}} private {{className}}(Kind kind, Object value) { this._kind = kind; this._value = value; } +{{/discriminated}} private {{className}}(Builder builder) { this._kind = {{TYPES.Client.Util.ApiTypeHelper}}.requireNonNull(builder._kind, builder, ""); @@ -30,7 +54,7 @@ return fn.apply(new Builder()).build(); } -{{#false}} +{{#canStringify}} public String _toJsonString() { switch (_kind) { {{#variants}} @@ -42,7 +66,7 @@ } } -{{/false}} +{{/canStringify}} {{#variants}} /** * Is this variant instance of kind {@code {{name}}}? @@ -56,7 +80,7 @@ * * @throws IllegalStateException if the current variant is not the {@code {{name}}} kind. */ - public {{type}} {{#camelCase}}{{name}}{{/camelCase}}() { + public {{type}} {{#asFieldName}}{{name}}{{/asFieldName}}() { return {{TYPES.Client.Util.TaggedUnionUtils}}.get(this, Kind.{{#pascalCase}}{{name}}{{/pascalCase}}); } @@ -64,9 +88,13 @@ @Override public void serialize({{TYPES.Jakarta.Json.Stream.JsonGenerator}} generator, {{TYPES.Client.Json.JsonpMapper}} mapper) { + {{#discriminated}} + mapper.serialize(_value, generator); + {{/discriminated}} + {{^discriminated}} if (_value instanceof {{TYPES.Client.Json.JsonpSerializable}}) { (({{TYPES.Client.Json.JsonpSerializable}}) _value).serialize(generator, mapper); - }{{#primitiveVariants}}{{#-first}} else { + }{{#nonShapeVariants}}{{#-first}} else { switch (_kind) { {{/-first}} case {{#pascalCase}}{{name}}{{/pascalCase}}: @@ -76,23 +104,24 @@ } } {{/-last}} - {{/primitiveVariants}} + {{/nonShapeVariants}} + {{/discriminated}} } public static class Builder extends {{TYPES.Client.Util.ObjectBuilderBase}} implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> { private Kind _kind; - private Object _value; + private {{variantBaseType}} _value; {{#variants}} - public {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> {{#camelCase}}{{name}}{{/camelCase}}({{type}} v) { + public {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> {{#asFieldName}}{{name}}{{/asFieldName}}({{type}} v) { this._kind = Kind.{{#pascalCase}}{{name}}{{/pascalCase}}; this._value = v; return this; } {{#type.hasBuilder}} - public {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> {{#camelCase}}{{name}}{{/camelCase}}({{type.builderFnType}} fn) { - return this.{{#camelCase}}{{name}}{{/camelCase}}(fn.apply(new {{type.builderType}}()).build()); + public {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> {{#asFieldName}}{{name}}{{/asFieldName}}({{type.builderFnType}} fn) { + return this.{{#asFieldName}}{{name}}{{/asFieldName}}(fn.apply(new {{type.builderType}}()).build()); } {{/type.hasBuilder}} @@ -104,13 +133,26 @@ } } +{{#discriminated}} + protected static void setup{{className}}Deserializer({{TYPES.Client.Json.ObjectDeserializer}} op) { + {{#variants}} + op.add(Builder::{{#asFieldName}}{{name}}{{/asFieldName}}, {{type}}._DESERIALIZER, {{#quoted}}{{name}}{{/quoted}}); + {{/variants}} + + op.setTypeProperty({{#quoted}}{{discriminatingField}}{{/quoted}}, {{#defaultVariant}}Kind.{{#pascalCase}}{{name}}{{/pascalCase}}.jsonValue(){{/defaultVariant}}{{^defaultVariant}}null{{/defaultVariant}}); + } + + public static final {{TYPES.Client.Json.JsonpDeserializer}}<{{className}}> _DESERIALIZER = {{TYPES.Client.Json.ObjectBuilderDeserializer}}.lazy(Builder::new, {{className}}::setup{{className}}Deserializer, Builder::build); +{{/discriminated}} +{{^discriminated}} private static {{TYPES.Client.Json.JsonpDeserializer}}<{{className}}> build{{className}}Deserializer() { - return new {{TYPES.Client.Json.UnionDeserializer.builderType}}<{{className}}, Kind, Object>({{className}}::new, false) + return new {{TYPES.Client.Json.UnionDeserializer.builderType}}<{{className}}, Kind, Object>({{className}}::new, {{hasAmbiguities}}) {{#variants}}.addMember(Kind.{{#pascalCase}}{{name}}{{/pascalCase}}, {{#type}}{{>Type/deserializer}}{{/type}}){{/variants}} .build(); } public static final {{TYPES.Client.Json.JsonpDeserializer}}<{{className}}> _DESERIALIZER = {{TYPES.Client.Json.JsonpDeserializer}}.lazy({{className}}::build{{className}}Deserializer); +{{/discriminated}} {{>TaggedUnionShape/HashCode}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/Builders.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/Builders.mustache new file mode 100644 index 0000000000..2e0fda8676 --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/Builders.mustache @@ -0,0 +1,12 @@ +{{>Partials/ClassDeclaration}} { + private {{className}}() {} + +{{#variants}} + /** + * Creates a builder for the {@link {{type.name}} {{name}}} {@code {{unionClassName}}} variant. + */ + public static {{type.builderType}} {{#asFieldName}}{{name}}{{/asFieldName}}() { + return new {{type.builderType}}(); + } +{{/variants}} +} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/Equals.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/Equals.mustache index ece94de59b..046ef327cb 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/Equals.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/Equals.mustache @@ -1,3 +1,4 @@ + @Override public boolean equals(Object o) { if(this == o) return true; if(o == null || this.getClass() != o.getClass()) return false; diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/HashCode.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/HashCode.mustache index eb7a1d39a1..68d2a29f3f 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/HashCode.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/HashCode.mustache @@ -1,3 +1,4 @@ + @Override public int hashCode() { int result = 17; result = 31 * result + {{TYPES.Java.Util.Objects}}.hashCode(this._kind); diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/VariantInterface.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/VariantInterface.mustache new file mode 100644 index 0000000000..bc0bdcbd6d --- /dev/null +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/TaggedUnionShape/VariantInterface.mustache @@ -0,0 +1,7 @@ +{{>Partials/ClassDeclaration}} { + {{unionClassName}}.Kind _{{#camelCase}}{{unionClassName}}{{/camelCase}}Kind(); + + default {{unionClassName}} _to{{unionClassName}}() { + return new {{unionClassName}}(this); + } +} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/directSerializer.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/directSerializer.mustache index 34f4345fca..1f4eec4047 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/directSerializer.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/directSerializer.mustache @@ -1,12 +1,30 @@ {{#type.isMap}} for ({{type.mapEntryType}} item{{depth}} : {{value}}.entrySet()) { generator.writeKey(item{{depth}}.getKey()); - {{#type.mapValueType.serializer}}item{{depth}}.getValue(){{/type.mapValueType.serializer}} + {{#type.mapValueType.isList}} + generator.writeStartArray(); + if (item{{depth}}.getValue() != null) { + {{#type.mapValueType.directSerializer}}item{{depth}}.getValue(){{/type.mapValueType.directSerializer}} + } + generator.writeEnd(); + {{/type.mapValueType.isList}} + {{^type.mapValueType.isList}} + {{#type.mapValueType.serializer}}item{{depth}}.getValue(){{/type.mapValueType.serializer}} + {{/type.mapValueType.isList}} } {{/type.isMap}} {{#type.isList}} for ({{type.listValueType}} item{{depth}} : {{value}}) { - {{#type.listValueType.serializer}}item{{depth}}{{/type.listValueType.serializer}} + {{#type.listValueType.isMap}} + generator.writeStartObject(); + if (item{{depth}} != null) { + {{#type.listValueType.directSerializer}}item{{depth}}{{/type.listValueType.directSerializer}} + } + generator.writeEnd(); + {{/type.listValueType.isMap}} + {{^type.listValueType.isMap}} + {{#type.listValueType.serializer}}item{{depth}}{{/type.listValueType.serializer}} + {{/type.listValueType.isMap}} } {{/type.isList}} {{^type.isListOrMap}}