Skip to content

Commit

Permalink
Fixes from spec 2549 (#800)
Browse files Browse the repository at this point in the history
* fixes from 2549

* test fix
  • Loading branch information
l-trotta authored May 8, 2024
1 parent 767ee11 commit 64ec619
Show file tree
Hide file tree
Showing 7 changed files with 204 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public abstract class WriteResponseBase implements JsonpSerializable {

private final Result result;

private final long seqNo;
@Nullable
private final Long seqNo;

private final ShardStatistics shards;

Expand All @@ -87,7 +88,7 @@ protected WriteResponseBase(AbstractBuilder<?> builder) {
this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index");
this.primaryTerm = builder.primaryTerm;
this.result = ApiTypeHelper.requireNonNull(builder.result, this, "result");
this.seqNo = ApiTypeHelper.requireNonNull(builder.seqNo, this, "seqNo");
this.seqNo = builder.seqNo;
this.shards = ApiTypeHelper.requireNonNull(builder.shards, this, "shards");
this.version = ApiTypeHelper.requireNonNull(builder.version, this, "version");
this.forcedRefresh = builder.forcedRefresh;
Expand Down Expand Up @@ -124,9 +125,10 @@ public final Result result() {
}

/**
* Required - API name: {@code _seq_no}
* API name: {@code _seq_no}
*/
public final long seqNo() {
@Nullable
public final Long seqNo() {
return this.seqNo;
}

Expand Down Expand Up @@ -176,9 +178,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
}
generator.writeKey("result");
this.result.serialize(generator, mapper);
generator.writeKey("_seq_no");
generator.write(this.seqNo);
if (this.seqNo != null) {
generator.writeKey("_seq_no");
generator.write(this.seqNo);

}
generator.writeKey("_shards");
this.shards.serialize(generator, mapper);

Expand Down Expand Up @@ -210,6 +214,7 @@ public abstract static class AbstractBuilder<BuilderT extends AbstractBuilder<Bu

private Result result;

@Nullable
private Long seqNo;

private ShardStatistics shards;
Expand Down Expand Up @@ -252,9 +257,9 @@ public final BuilderT result(Result value) {
}

/**
* Required - API name: {@code _seq_no}
* API name: {@code _seq_no}
*/
public final BuilderT seqNo(long value) {
public final BuilderT seqNo(@Nullable Long value) {
this.seqNo = value;
return self();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@
public class AdjacencyMatrixAggregation extends BucketAggregationBase implements AggregationVariant, JsonpSerializable {
private final Map<String, Query> filters;

@Nullable
private final String separator;

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

private AdjacencyMatrixAggregation(Builder builder) {

this.filters = ApiTypeHelper.unmodifiable(builder.filters);
this.separator = builder.separator;

}

Expand All @@ -92,6 +96,16 @@ public final Map<String, Query> filters() {
return this.filters;
}

/**
* Separator used to concatenate filter names. Defaults to &amp;.
* <p>
* API name: {@code separator}
*/
@Nullable
public final String separator() {
return this.separator;
}

/**
* Serialize this object to JSON.
*/
Expand All @@ -114,6 +128,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeEnd();

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

}

}

Expand All @@ -134,6 +153,9 @@ public static class Builder extends BucketAggregationBase.AbstractBuilder<Builde
@Nullable
private Map<String, Query> filters;

@Nullable
private String separator;

/**
* Filters used to create buckets. At least one filter is required.
* <p>
Expand Down Expand Up @@ -169,6 +191,16 @@ public final Builder filters(String key, Function<Query.Builder, ObjectBuilder<Q
return filters(key, fn.apply(new Query.Builder()).build());
}

/**
* Separator used to concatenate filter names. Defaults to &amp;.
* <p>
* API name: {@code separator}
*/
public final Builder separator(@Nullable String value) {
this.separator = value;
return this;
}

@Override
protected Builder self() {
return this;
Expand Down Expand Up @@ -199,6 +231,7 @@ protected static void setupAdjacencyMatrixAggregationDeserializer(
ObjectDeserializer<AdjacencyMatrixAggregation.Builder> op) {

op.add(Builder::filters, JsonpDeserializer.stringMapDeserializer(Query._DESERIALIZER), "filters");
op.add(Builder::separator, JsonpDeserializer.stringDeserializer(), "separator");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
*/
@JsonpDeserializable
public class DenseVectorProperty extends PropertyBase implements PropertyVariant {
@Nullable
private final String elementType;

@Nullable
private final Integer dims;

Expand All @@ -75,6 +78,7 @@ public class DenseVectorProperty extends PropertyBase implements PropertyVariant
private DenseVectorProperty(Builder builder) {
super(builder);

this.elementType = builder.elementType;
this.dims = builder.dims;
this.similarity = builder.similarity;
this.index = builder.index;
Expand All @@ -94,6 +98,14 @@ public Property.Kind _propertyKind() {
return Property.Kind.DenseVector;
}

/**
* API name: {@code element_type}
*/
@Nullable
public final String elementType() {
return this.elementType;
}

/**
* API name: {@code dims}
*/
Expand Down Expand Up @@ -130,6 +142,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

generator.write("type", "dense_vector");
super.serializeInternal(generator, mapper);
if (this.elementType != null) {
generator.writeKey("element_type");
generator.write(this.elementType);

}
if (this.dims != null) {
generator.writeKey("dims");
generator.write(this.dims);
Expand Down Expand Up @@ -162,6 +179,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
public static class Builder extends PropertyBase.AbstractBuilder<Builder>
implements
ObjectBuilder<DenseVectorProperty> {
@Nullable
private String elementType;

@Nullable
private Integer dims;

Expand All @@ -174,6 +194,14 @@ public static class Builder extends PropertyBase.AbstractBuilder<Builder>
@Nullable
private DenseVectorIndexOptions indexOptions;

/**
* API name: {@code element_type}
*/
public final Builder elementType(@Nullable String value) {
this.elementType = value;
return this;
}

/**
* API name: {@code dims}
*/
Expand Down Expand Up @@ -242,6 +270,7 @@ public DenseVectorProperty build() {

protected static void setupDenseVectorPropertyDeserializer(ObjectDeserializer<DenseVectorProperty.Builder> op) {
PropertyBase.setupPropertyBaseDeserializer(op);
op.add(Builder::elementType, JsonpDeserializer.stringDeserializer(), "element_type");
op.add(Builder::dims, JsonpDeserializer.integerDeserializer(), "dims");
op.add(Builder::similarity, JsonpDeserializer.stringDeserializer(), "similarity");
op.add(Builder::index, JsonpDeserializer.booleanDeserializer(), "index");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@
public class PutComponentTemplateRequest extends RequestBase implements JsonpSerializable {
private final Map<String, JsonData> meta;

@Nullable
private final String cause;

@Nullable
private final Boolean create;

Expand All @@ -116,7 +113,6 @@ public class PutComponentTemplateRequest extends RequestBase implements JsonpSer
private PutComponentTemplateRequest(Builder builder) {

this.meta = ApiTypeHelper.unmodifiable(builder.meta);
this.cause = builder.cause;
this.create = builder.create;
this.deprecated = builder.deprecated;
this.masterTimeout = builder.masterTimeout;
Expand All @@ -142,14 +138,6 @@ public final Map<String, JsonData> meta() {
return this.meta;
}

/**
* API name: {@code cause}
*/
@Nullable
public final String cause() {
return this.cause;
}

/**
* If <code>true</code>, this request cannot replace or update existing
* component templates.
Expand Down Expand Up @@ -268,9 +256,6 @@ public static class Builder extends RequestBase.AbstractBuilder<Builder>
@Nullable
private Map<String, JsonData> meta;

@Nullable
private String cause;

@Nullable
private Boolean create;

Expand Down Expand Up @@ -317,14 +302,6 @@ public final Builder meta(String key, JsonData value) {
return this;
}

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

/**
* If <code>true</code>, this request cannot replace or update existing
* component templates.
Expand Down Expand Up @@ -508,9 +485,6 @@ protected static void setupPutComponentTemplateRequestDeserializer(
if (request.create != null) {
params.put("create", String.valueOf(request.create));
}
if (request.cause != null) {
params.put("cause", request.cause);
}
return params;

}, SimpleEndpoint.emptyMap(), true, PutComponentTemplateResponse._DESERIALIZER);
Expand Down
Loading

0 comments on commit 64ec619

Please sign in to comment.