diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/IndexSettingsSimilarity.java b/java-client/src/main/java/org/opensearch/client/opensearch/indices/IndexSettingsSimilarity.java new file mode 100644 index 0000000000..46336c0a87 --- /dev/null +++ b/java-client/src/main/java/org/opensearch/client/opensearch/indices/IndexSettingsSimilarity.java @@ -0,0 +1,123 @@ +package org.opensearch.client.opensearch.indices; + + +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; +import org.opensearch.client.json.JsonEnum; +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.JsonpSerializable; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.util.ApiTypeHelper; +import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ObjectBuilderBase; +import org.opensearch.client.util.TaggedUnion; + + + +@JsonpDeserializable +public class IndexSettingsSimilarity implements TaggedUnion, JsonpSerializable { + + + public enum Kind implements JsonEnum { + Bm25("BM25"), + + Boolean("boolean"), + + ; + + private final String jsonValue; + + Kind(String jsonValue) { + this.jsonValue = jsonValue; + } + + public String jsonValue() { + return this.jsonValue; + } + + } + + private final Kind _kind; + private final IndexSettingsSimilarityVariant _value; + + public final Kind _kind() { + return _kind; + } + + public final IndexSettingsSimilarityVariant _get() { + return _value; + } + + public IndexSettingsSimilarity(IndexSettingsSimilarityVariant value) { + + this._kind = ApiTypeHelper.requireNonNull(value._settingsSimilarityKind(), this, ""); + this._value = ApiTypeHelper.requireNonNull(value, this, ""); + + } + + private IndexSettingsSimilarity(Builder builder) { + + this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, ""); + this._value = ApiTypeHelper.requireNonNull(builder._value, builder, ""); + + } + + public static IndexSettingsSimilarity of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + mapper.serialize(_value, generator); + } + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + private Kind _kind; + private IndexSettingsSimilarityVariant _value; + + public ObjectBuilder bm25(IndexSettingsSimilarityBm25 v) { + this._kind = Kind.Bm25; + this._value = v; + return this; + } + + public ObjectBuilder bm25( + Function> fn) { + return this.bm25(fn.apply(new IndexSettingsSimilarityBm25.Builder()).build()); + } + + public ObjectBuilder boolean_(IndexSettingsSimilarityBoolean v) { + this._kind = Kind.Boolean; + this._value = v; + return this; + } + + public ObjectBuilder boolean_( + Function> fn) { + return this.boolean_(fn.apply(new IndexSettingsSimilarityBoolean.Builder()).build()); + } + + + @Override + public IndexSettingsSimilarity build() { + _checkSingleUse(); + return new IndexSettingsSimilarity(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer + .lazy(Builder::new, IndexSettingsSimilarity::setupIndexSettingsSimilarityDeserializer, Builder::build); + + protected static void setupIndexSettingsSimilarityDeserializer(ObjectDeserializer op) { + + op.add(Builder::bm25, IndexSettingsSimilarityBm25._DESERIALIZER, "BM25"); + op.add(Builder::boolean_, IndexSettingsSimilarityBoolean._DESERIALIZER, "boolean"); + + op.setTypeProperty("type", null); + + } + +} \ No newline at end of file diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/IndexSettingsSimilarityBm25.java b/java-client/src/main/java/org/opensearch/client/opensearch/indices/IndexSettingsSimilarityBm25.java new file mode 100644 index 0000000000..4cdd1e92e4 --- /dev/null +++ b/java-client/src/main/java/org/opensearch/client/opensearch/indices/IndexSettingsSimilarityBm25.java @@ -0,0 +1,142 @@ +package org.opensearch.client.opensearch.indices; + +import jakarta.json.stream.JsonGenerator; +import javax.annotation.Nullable; +import java.util.function.Function; +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.JsonpSerializable; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ObjectBuilderBase; + + +@JsonpDeserializable +public class IndexSettingsSimilarityBm25 implements IndexSettingsSimilarityVariant, JsonpSerializable { + + @Nullable + private final Double b; + + @Nullable + private final Boolean discountOverlaps; + + @Nullable + private final Double k1; + + + private IndexSettingsSimilarityBm25(Builder builder) { + + this.b = builder.b; + this.discountOverlaps = builder.discountOverlaps; + this.k1 = builder.k1; + + } + + public static IndexSettingsSimilarityBm25 of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + + @Override + public IndexSettingsSimilarity.Kind _settingsSimilarityKind() { + return IndexSettingsSimilarity.Kind.Bm25; + } + + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", "BM25"); + + if (this.b != null) { + generator.writeKey("b"); + generator.write(this.b); + + } + if (this.discountOverlaps != null) { + generator.writeKey("discount_overlaps"); + generator.write(this.discountOverlaps); + + } + if (this.k1 != null) { + generator.writeKey("k1"); + generator.write(this.k1); + + } + + } + + /** + * Builder for {@link IndexSettingsSimilarityBm25}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + + @Nullable + private Double b; + + @Nullable + private Boolean discountOverlaps; + + @Nullable + private Double k1; + + /** + * API name: {@code b} + */ + public final Builder b(@Nullable Double value) { + this.b = value; + return this; + } + + /** + * API name: {@code discount_overlaps} + */ + public final Builder discountOverlaps(@Nullable Boolean value) { + this.discountOverlaps = value; + return this; + } + + /** + * API name: {@code k1} + */ + public final Builder k1(@Nullable Double value) { + this.k1 = value; + return this; + } + + /** + * Builds a {@link IndexSettingsSimilarityBm25}. + * + * @throws NullPointerException if some of the required fields are null. + */ + + public IndexSettingsSimilarityBm25 build() { + _checkSingleUse(); + + return new IndexSettingsSimilarityBm25(this); + } + } + + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + IndexSettingsSimilarityBm25::setupIndexSettingsSimilarityBm25Deserializer + ); + + protected static void setupIndexSettingsSimilarityBm25Deserializer(ObjectDeserializer op) { + + op.add(Builder::b, JsonpDeserializer.doubleDeserializer(), "b"); + op.add(Builder::discountOverlaps, JsonpDeserializer.booleanDeserializer(), "discount_overlaps"); + op.add(Builder::k1, JsonpDeserializer.doubleDeserializer(), "k1"); + + op.ignore("type"); + } + +} \ No newline at end of file diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/IndexSettingsSimilarityBoolean.java b/java-client/src/main/java/org/opensearch/client/opensearch/indices/IndexSettingsSimilarityBoolean.java new file mode 100644 index 0000000000..55e17a5280 --- /dev/null +++ b/java-client/src/main/java/org/opensearch/client/opensearch/indices/IndexSettingsSimilarityBoolean.java @@ -0,0 +1,70 @@ +package org.opensearch.client.opensearch.indices; + + +import jakarta.json.stream.JsonGenerator; +import java.util.function.Function; +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.JsonpSerializable; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.util.ObjectBuilder; +import org.opensearch.client.util.ObjectBuilderBase; + + +@JsonpDeserializable +public class IndexSettingsSimilarityBoolean implements IndexSettingsSimilarityVariant, JsonpSerializable { + + private IndexSettingsSimilarityBoolean(Builder builder) { + + } + + public static IndexSettingsSimilarityBoolean of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + + @Override + public IndexSettingsSimilarity.Kind _settingsSimilarityKind() { + return IndexSettingsSimilarity.Kind.Boolean; + } + + @Override + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + generator.write("type", "boolean"); + + } + + + /** + * Builder for {@link IndexSettingsSimilarityBoolean}. + */ + + public static class Builder extends ObjectBuilderBase implements ObjectBuilder { + + public IndexSettingsSimilarityBoolean build() { + _checkSingleUse(); + + return new IndexSettingsSimilarityBoolean(this); + } + } + + + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( + Builder::new, + IndexSettingsSimilarityBoolean::setupIndexSettingsSimilarityBooleanDeserializer + ); + + protected static void setupIndexSettingsSimilarityBooleanDeserializer(ObjectDeserializer op) { + + op.ignore("type"); + } +} \ No newline at end of file diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/IndexSettingsSimilarityVariant.java b/java-client/src/main/java/org/opensearch/client/opensearch/indices/IndexSettingsSimilarityVariant.java new file mode 100644 index 0000000000..14a41f84a8 --- /dev/null +++ b/java-client/src/main/java/org/opensearch/client/opensearch/indices/IndexSettingsSimilarityVariant.java @@ -0,0 +1,14 @@ +package org.opensearch.client.opensearch.indices; + + +import org.opensearch.client.json.JsonpSerializable; + +public interface IndexSettingsSimilarityVariant extends JsonpSerializable { + + IndexSettingsSimilarity.Kind _settingsSimilarityKind(); + + default IndexSettingsSimilarity _toSettingsSimilarity() { + return new IndexSettingsSimilarity(this); + } + +} \ No newline at end of file