Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* specification</a>
*/
@JsonpDeserializable
public class DenseVectorIndexOptions implements SemanticTextIndexOptionsVariant, JsonpSerializable {
public class DenseVectorIndexOptions implements JsonpSerializable {
@Nullable
private final Float confidenceInterval;

Expand All @@ -87,14 +87,6 @@ public static DenseVectorIndexOptions of(Function<Builder, ObjectBuilder<DenseVe
return fn.apply(new Builder()).build();
}

/**
* SemanticTextIndexOptions variant kind.
*/
@Override
public SemanticTextIndexOptions.Kind _semanticTextIndexOptionsKind() {
return SemanticTextIndexOptions.Kind.DenseVector;
}

/**
* The confidence interval to use when quantizing the vectors. Can be any value
* between and including <code>0.90</code> and <code>1.0</code> or exactly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,16 @@

package co.elastic.clients.elasticsearch._types.mapping;

import co.elastic.clients.json.JsonEnum;
import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.json.JsonpMapper;
import co.elastic.clients.json.JsonpSerializable;
import co.elastic.clients.json.JsonpUtils;
import co.elastic.clients.json.ObjectBuilderDeserializer;
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.util.ApiTypeHelper;
import co.elastic.clients.util.ObjectBuilder;
import co.elastic.clients.util.TaggedUnion;
import co.elastic.clients.util.TaggedUnionUtils;
import co.elastic.clients.util.WithJsonObjectBuilderBase;
import jakarta.json.stream.JsonGenerator;
import java.lang.Object;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -62,57 +57,15 @@
* specification</a>
*/
@JsonpDeserializable
public class SemanticTextIndexOptions implements TaggedUnion<SemanticTextIndexOptions.Kind, Object>, JsonpSerializable {
public class SemanticTextIndexOptions implements JsonpSerializable {
@Nullable
private final DenseVectorIndexOptions denseVector;

/**
* {@link SemanticTextIndexOptions} variant kinds.
*
* @see <a href=
* "../../doc-files/api-spec.html#_types.mapping.SemanticTextIndexOptions">API
* specification</a>
*/

public enum Kind implements JsonEnum {
DenseVector("dense_vector"),

;

private final String jsonValue;

Kind(String jsonValue) {
this.jsonValue = jsonValue;
}

public String jsonValue() {
return this.jsonValue;
}

}

private final Kind _kind;
private final Object _value;

@Override
public final Kind _kind() {
return _kind;
}

@Override
public final Object _get() {
return _value;
}

public SemanticTextIndexOptions(SemanticTextIndexOptionsVariant value) {

this._kind = ApiTypeHelper.requireNonNull(value._semanticTextIndexOptionsKind(), this, "<variant kind>");
this._value = ApiTypeHelper.requireNonNull(value, this, "<variant value>");

}
// ---------------------------------------------------------------------------------------------

private SemanticTextIndexOptions(Builder builder) {

this._kind = ApiTypeHelper.requireNonNull(builder._kind, builder, "<variant kind>");
this._value = ApiTypeHelper.requireNonNull(builder._value, builder, "<variant value>");
this.denseVector = builder.denseVector;

}

Expand All @@ -121,76 +74,108 @@ public static SemanticTextIndexOptions of(Function<Builder, ObjectBuilder<Semant
}

/**
* Is this variant instance of kind {@code dense_vector}?
* API name: {@code dense_vector}
*/
public boolean isDenseVector() {
return _kind == Kind.DenseVector;
@Nullable
public final DenseVectorIndexOptions denseVector() {
return this.denseVector;
}

/**
* Get the {@code dense_vector} variant value.
*
* @throws IllegalStateException
* if the current variant is not of the {@code dense_vector} kind.
* Serialize this object to JSON.
*/
public DenseVectorIndexOptions denseVector() {
return TaggedUnionUtils.get(this, Kind.DenseVector);
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
generator.writeStartObject();
serializeInternal(generator, mapper);
generator.writeEnd();
}

@Override
@SuppressWarnings("unchecked")
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

generator.writeStartObject();
if (this.denseVector != null) {
generator.writeKey("dense_vector");
this.denseVector.serialize(generator, mapper);

generator.writeKey(_kind.jsonValue());
if (_value instanceof JsonpSerializable) {
((JsonpSerializable) _value).serialize(generator, mapper);
}

generator.writeEnd();

}

@Override
public String toString() {
return JsonpUtils.toString(this);
}

// ---------------------------------------------------------------------------------------------

/**
* Builder for {@link SemanticTextIndexOptions}.
*/

public static class Builder extends WithJsonObjectBuilderBase<Builder>
implements
ObjectBuilder<SemanticTextIndexOptions> {
private Kind _kind;
private Object _value;
@Nullable
private DenseVectorIndexOptions denseVector;

@Override
protected Builder self() {
return this;
public Builder() {
}
public ObjectBuilder<SemanticTextIndexOptions> denseVector(DenseVectorIndexOptions v) {
this._kind = Kind.DenseVector;
this._value = v;
private Builder(SemanticTextIndexOptions instance) {
this.denseVector = instance.denseVector;

}
/**
* API name: {@code dense_vector}
*/
public final Builder denseVector(@Nullable DenseVectorIndexOptions value) {
this.denseVector = value;
return this;
}

public ObjectBuilder<SemanticTextIndexOptions> denseVector(
/**
* API name: {@code dense_vector}
*/
public final Builder denseVector(
Function<DenseVectorIndexOptions.Builder, ObjectBuilder<DenseVectorIndexOptions>> fn) {
return this.denseVector(fn.apply(new DenseVectorIndexOptions.Builder()).build());
}

@Override
protected Builder self() {
return this;
}

/**
* Builds a {@link SemanticTextIndexOptions}.
*
* @throws NullPointerException
* if some of the required fields are null.
*/
public SemanticTextIndexOptions build() {
_checkSingleUse();

return new SemanticTextIndexOptions(this);
}
}

/**
* @return New {@link Builder} initialized with field values of this instance
*/
public Builder rebuild() {
return new Builder(this);
}
// ---------------------------------------------------------------------------------------------

/**
* Json deserializer for {@link SemanticTextIndexOptions}
*/
public static final JsonpDeserializer<SemanticTextIndexOptions> _DESERIALIZER = ObjectBuilderDeserializer
.lazy(Builder::new, SemanticTextIndexOptions::setupSemanticTextIndexOptionsDeserializer);

protected static void setupSemanticTextIndexOptionsDeserializer(ObjectDeserializer<Builder> op) {
protected static void setupSemanticTextIndexOptionsDeserializer(
ObjectDeserializer<SemanticTextIndexOptions.Builder> op) {

op.add(Builder::denseVector, DenseVectorIndexOptions._DESERIALIZER, "dense_vector");

}

public static final JsonpDeserializer<SemanticTextIndexOptions> _DESERIALIZER = ObjectBuilderDeserializer
.lazy(Builder::new, SemanticTextIndexOptions::setupSemanticTextIndexOptionsDeserializer, Builder::build);
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -340,17 +340,6 @@ public final Builder indexOptions(
return this.indexOptions(fn.apply(new SemanticTextIndexOptions.Builder()).build());
}

/**
* Settings for index_options that override any defaults used by semantic_text,
* for example specific quantization settings.
* <p>
* API name: {@code index_options}
*/
public final Builder indexOptions(SemanticTextIndexOptionsVariant value) {
this.indexOptions = value._toSemanticTextIndexOptions();
return this;
}

/**
* Settings for chunking text into smaller passages. If specified, these will
* override the chunking settings sent in the inference endpoint associated with
Expand Down
Loading
Loading