Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding missing parameter and fixing recent bugs #868

Merged
merged 1 commit into from
Aug 22, 2024
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 @@ -72,6 +72,9 @@ public class KnnQuery extends QueryBase implements QueryVariant {
@Nullable
private final Integer numCandidates;

@Nullable
private final Integer k;

private final List<Query> filter;

@Nullable
Expand All @@ -86,6 +89,7 @@ private KnnQuery(Builder builder) {
this.queryVector = ApiTypeHelper.unmodifiable(builder.queryVector);
this.queryVectorBuilder = builder.queryVectorBuilder;
this.numCandidates = builder.numCandidates;
this.k = builder.k;
this.filter = ApiTypeHelper.unmodifiable(builder.filter);
this.similarity = builder.similarity;

Expand Down Expand Up @@ -142,6 +146,16 @@ public final Integer numCandidates() {
return this.numCandidates;
}

/**
* The final number of nearest neighbors to return as top hits
* <p>
* API name: {@code k}
*/
@Nullable
public final Integer k() {
return this.k;
}

/**
* Filters for the kNN search query
* <p>
Expand Down Expand Up @@ -186,6 +200,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeKey("num_candidates");
generator.write(this.numCandidates);

}
if (this.k != null) {
generator.writeKey("k");
generator.write(this.k);

}
if (ApiTypeHelper.isDefined(this.filter)) {
generator.writeKey("filter");
Expand Down Expand Up @@ -223,6 +242,9 @@ public static class Builder extends QueryBase.AbstractBuilder<Builder> implement
@Nullable
private Integer numCandidates;

@Nullable
private Integer k;

@Nullable
private List<Query> filter;

Expand Down Expand Up @@ -295,6 +317,16 @@ public final Builder numCandidates(@Nullable Integer value) {
return this;
}

/**
* The final number of nearest neighbors to return as top hits
* <p>
* API name: {@code k}
*/
public final Builder k(@Nullable Integer value) {
this.k = value;
return this;
}

/**
* Filters for the kNN search query
* <p>
Expand Down Expand Up @@ -373,6 +405,7 @@ protected static void setupKnnQueryDeserializer(ObjectDeserializer<KnnQuery.Buil
"query_vector");
op.add(Builder::queryVectorBuilder, QueryVectorBuilder._DESERIALIZER, "query_vector_builder");
op.add(Builder::numCandidates, JsonpDeserializer.integerDeserializer(), "num_candidates");
op.add(Builder::k, JsonpDeserializer.integerDeserializer(), "k");
op.add(Builder::filter, JsonpDeserializer.arrayDeserializer(Query._DESERIALIZER), "filter");
op.add(Builder::similarity, JsonpDeserializer.floatDeserializer(), "similarity");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import co.elastic.clients.json.JsonpMapper;
import co.elastic.clients.json.ObjectBuilderDeserializer;
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.util.ApiTypeHelper;
import co.elastic.clients.util.ObjectBuilder;
import jakarta.json.stream.JsonGenerator;
import java.lang.String;
Expand Down Expand Up @@ -56,6 +57,9 @@
*/
@JsonpDeserializable
public class DateRangeQuery extends RangeQueryBase<String> implements RangeQueryVariant {
// Single key dictionary
private final String field;

@Nullable
private final String format;

Expand All @@ -66,6 +70,7 @@ public class DateRangeQuery extends RangeQueryBase<String> implements RangeQuery

private DateRangeQuery(Builder builder) {
super(builder);
this.field = ApiTypeHelper.requireNonNull(builder.field, this, "field");

this.format = builder.format;
this.timeZone = builder.timeZone;
Expand All @@ -84,6 +89,13 @@ public RangeQuery.Kind _rangeQueryKind() {
return RangeQuery.Kind.Date;
}

/**
* Required - the required field
*/
public final String field() {
return this.field;
}

/**
* Date format used to convert <code>date</code> values in the query.
* <p>
Expand All @@ -106,6 +118,7 @@ public final String timeZone() {
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeStartObject(this.field);

super.serializeInternal(generator, mapper);
if (this.format != null) {
Expand All @@ -119,6 +132,8 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

generator.writeEnd();

}

// ---------------------------------------------------------------------------------------------
Expand All @@ -130,6 +145,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
public static class Builder extends RangeQueryBase.AbstractBuilder<String, Builder>
implements
ObjectBuilder<DateRangeQuery> {
private String field;

/**
* Required - the required field
*/
public final Builder field(String value) {
this.field = value;
return this;
}

@Nullable
private String format;

Expand Down Expand Up @@ -189,6 +214,8 @@ protected static void setupDateRangeQueryDeserializer(ObjectDeserializer<DateRan
op.add(Builder::format, JsonpDeserializer.stringDeserializer(), "format");
op.add(Builder::timeZone, JsonpDeserializer.stringDeserializer(), "time_zone");

op.setKey(Builder::field, JsonpDeserializer.stringDeserializer());

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@

import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;
import co.elastic.clients.json.JsonpMapper;
import co.elastic.clients.json.ObjectBuilderDeserializer;
import co.elastic.clients.json.ObjectDeserializer;
import co.elastic.clients.util.ApiTypeHelper;
import co.elastic.clients.util.ObjectBuilder;
import jakarta.json.stream.JsonGenerator;
import java.lang.Double;
import java.lang.String;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;

//----------------------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
Expand All @@ -54,10 +58,14 @@
*/
@JsonpDeserializable
public class NumberRangeQuery extends RangeQueryBase<Double> implements RangeQueryVariant {
// Single key dictionary
private final String field;

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

private NumberRangeQuery(Builder builder) {
super(builder);
this.field = ApiTypeHelper.requireNonNull(builder.field, this, "field");

}

Expand All @@ -73,6 +81,22 @@ public RangeQuery.Kind _rangeQueryKind() {
return RangeQuery.Kind.Number;
}

/**
* Required - the required field
*/
public final String field() {
return this.field;
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeStartObject(this.field);

super.serializeInternal(generator, mapper);

generator.writeEnd();

}

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

/**
Expand All @@ -82,6 +106,16 @@ public RangeQuery.Kind _rangeQueryKind() {
public static class Builder extends RangeQueryBase.AbstractBuilder<Double, Builder>
implements
ObjectBuilder<NumberRangeQuery> {
private String field;

/**
* Required - the required field
*/
public final Builder field(String value) {
this.field = value;
return this;
}

@Override
protected Builder self() {
return this;
Expand Down Expand Up @@ -112,6 +146,8 @@ public NumberRangeQuery build() {
protected static void setupNumberRangeQueryDeserializer(ObjectDeserializer<NumberRangeQuery.Builder> op) {
RangeQueryBase.setupRangeQueryBaseDeserializer(op, JsonpDeserializer.doubleDeserializer());

op.setKey(Builder::field, JsonpDeserializer.stringDeserializer());

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@
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.WithJsonObjectBuilderBase;
import jakarta.json.stream.JsonGenerator;
import java.lang.String;
import java.util.Objects;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -59,9 +57,6 @@
*/

public abstract class RangeQueryBase<T> extends QueryBase {
// Single key dictionary
private final String field;

@Nullable
private final RangeRelation relation;

Expand Down Expand Up @@ -90,7 +85,6 @@ public abstract class RangeQueryBase<T> extends QueryBase {

protected RangeQueryBase(AbstractBuilder<T, ?> builder) {
super(builder);
this.field = ApiTypeHelper.requireNonNull(builder.field, this, "field");

this.relation = builder.relation;
this.gt = builder.gt;
Expand All @@ -103,13 +97,6 @@ protected RangeQueryBase(AbstractBuilder<T, ?> builder) {

}

/**
* Required - the required field
*/
public final String field() {
return this.field;
}

/**
* Indicates how the range query matches values for <code>range</code> fields.
* <p>
Expand Down Expand Up @@ -177,7 +164,6 @@ public final T to() {
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeStartObject(this.field);

super.serializeInternal(generator, mapper);
if (this.relation != null) {
Expand Down Expand Up @@ -215,23 +201,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

generator.writeEnd();

}

public abstract static class AbstractBuilder<T, BuilderT extends AbstractBuilder<T, BuilderT>>
extends
QueryBase.AbstractBuilder<BuilderT> {
private String field;

/**
* Required - the required field
*/
public final BuilderT field(String value) {
this.field = value;
return self();
}

@Nullable
private RangeRelation relation;

Expand Down Expand Up @@ -345,8 +319,6 @@ protected static <T, BuilderT extends AbstractBuilder<T, BuilderT>> void setupRa
op.add(AbstractBuilder::from, tDeserializer, "from");
op.add(AbstractBuilder::to, tDeserializer, "to");

op.setKey(AbstractBuilder::field, JsonpDeserializer.stringDeserializer());

}

}
Loading
Loading