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

Added size attribute to MultiTermsAggregation #614

Closed
wants to merge 5 commits into from
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Added
- Added support for "smartcn" analyzer ([#605](https://github.com/opensearch-project/opensearch-java/pull/605))
- Added support for "cjk" analyzer ([#604](https://github.com/opensearch-project/opensearch-java/pull/604))
- Added size attribute to MultiTermsAggregation ([#614](https://github.com/opensearch-project/opensearch-java/pull/614))

### Dependencies
- Bumps `org.ajoberstar.grgit:grgit-gradle` from 5.0.0 to 5.2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,24 @@
import java.util.List;
import java.util.function.Function;

import javax.annotation.Nullable;

// typedef: _types.aggregations.MultiTermsAggregation

@JsonpDeserializable
public class MultiTermsAggregation extends BucketAggregationBase implements AggregationVariant {
private final List<MultiTermLookup> terms;

@Nullable
private final Integer size;

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

private MultiTermsAggregation(Builder builder) {
super(builder);

this.terms = ApiTypeHelper.unmodifiableRequired(builder.terms, this, "terms");

this.size = builder.size;
}

public static MultiTermsAggregation of(Function<Builder, ObjectBuilder<MultiTermsAggregation>> fn) {
Expand All @@ -77,9 +82,22 @@ public final List<MultiTermLookup> terms() {
return this.terms;
}

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

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

super.serializeInternal(generator, mapper);
if (this.size != null) {
generator.writeKey("size");
generator.write(this.size);

}
if (ApiTypeHelper.isDefined(this.terms)) {
generator.writeKey("terms");
generator.writeStartArray();
Expand All @@ -104,6 +122,9 @@ public static class Builder extends BucketAggregationBase.AbstractBuilder<Builde
ObjectBuilder<MultiTermsAggregation> {
private List<MultiTermLookup> terms;

@Nullable
private Integer size;

/**
* Required - API name: {@code terms}
* <p>
Expand Down Expand Up @@ -133,6 +154,14 @@ public final Builder terms(Function<MultiTermLookup.Builder, ObjectBuilder<Multi
return terms(fn.apply(new MultiTermLookup.Builder()).build());
}

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

@Override
protected Builder self() {
return this;
Expand Down Expand Up @@ -161,8 +190,8 @@ public MultiTermsAggregation build() {

protected static void setupMultiTermsAggregationDeserializer(ObjectDeserializer<MultiTermsAggregation.Builder> op) {
BucketAggregationBase.setupBucketAggregationBaseDeserializer(op);
op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size");
op.add(Builder::terms, JsonpDeserializer.arrayDeserializer(MultiTermLookup._DESERIALIZER), "terms");

}

}
Loading