35
35
import jakarta .json .stream .JsonGenerator ;
36
36
import java .lang .Boolean ;
37
37
import java .lang .Integer ;
38
+ import java .lang .Long ;
38
39
import java .lang .String ;
39
40
import java .util .List ;
40
41
import java .util .Objects ;
@@ -101,6 +102,9 @@ public class TermsAggregation extends BucketAggregationBase implements Aggregati
101
102
@ Nullable
102
103
private final Script script ;
103
104
105
+ @ Nullable
106
+ private final Long shardMinDocCount ;
107
+
104
108
@ Nullable
105
109
private final Integer shardSize ;
106
110
@@ -127,6 +131,7 @@ private TermsAggregation(Builder builder) {
127
131
this .valueType = builder .valueType ;
128
132
this .order = ApiTypeHelper .unmodifiable (builder .order );
129
133
this .script = builder .script ;
134
+ this .shardMinDocCount = builder .shardMinDocCount ;
130
135
this .shardSize = builder .shardSize ;
131
136
this .showTermDocCountError = builder .showTermDocCountError ;
132
137
this .size = builder .size ;
@@ -249,6 +254,23 @@ public final Script script() {
249
254
}
250
255
251
256
/**
257
+ * Regulates the certainty a shard has if the term should actually be added to
258
+ * the candidate list or not with respect to the <code>min_doc_count</code>.
259
+ * Terms will only be considered if their local shard frequency within the set
260
+ * is higher than the <code>shard_min_doc_count</code>.
261
+ * <p>
262
+ * API name: {@code shard_min_doc_count}
263
+ */
264
+ @ Nullable
265
+ public final Long shardMinDocCount () {
266
+ return this .shardMinDocCount ;
267
+ }
268
+
269
+ /**
270
+ * The number of candidate terms produced by each shard. By default,
271
+ * <code>shard_size</code> will be automatically estimated based on the number
272
+ * of shards and the <code>size</code> parameter.
273
+ * <p>
252
274
* API name: {@code shard_size}
253
275
*/
254
276
@ Nullable
@@ -339,6 +361,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
339
361
generator .writeKey ("script" );
340
362
this .script .serialize (generator , mapper );
341
363
364
+ }
365
+ if (this .shardMinDocCount != null ) {
366
+ generator .writeKey ("shard_min_doc_count" );
367
+ generator .write (this .shardMinDocCount );
368
+
342
369
}
343
370
if (this .shardSize != null ) {
344
371
generator .writeKey ("shard_size" );
@@ -403,6 +430,9 @@ public static class Builder extends BucketAggregationBase.AbstractBuilder<Builde
403
430
@ Nullable
404
431
private Script script ;
405
432
433
+ @ Nullable
434
+ private Long shardMinDocCount ;
435
+
406
436
@ Nullable
407
437
private Integer shardSize ;
408
438
@@ -581,6 +611,23 @@ public final Builder script(Function<Script.Builder, ObjectBuilder<Script>> fn)
581
611
}
582
612
583
613
/**
614
+ * Regulates the certainty a shard has if the term should actually be added to
615
+ * the candidate list or not with respect to the <code>min_doc_count</code>.
616
+ * Terms will only be considered if their local shard frequency within the set
617
+ * is higher than the <code>shard_min_doc_count</code>.
618
+ * <p>
619
+ * API name: {@code shard_min_doc_count}
620
+ */
621
+ public final Builder shardMinDocCount (@ Nullable Long value ) {
622
+ this .shardMinDocCount = value ;
623
+ return this ;
624
+ }
625
+
626
+ /**
627
+ * The number of candidate terms produced by each shard. By default,
628
+ * <code>shard_size</code> will be automatically estimated based on the number
629
+ * of shards and the <code>size</code> parameter.
630
+ * <p>
584
631
* API name: {@code shard_size}
585
632
*/
586
633
public final Builder shardSize (@ Nullable Integer value ) {
@@ -645,6 +692,7 @@ protected static void setupTermsAggregationDeserializer(ObjectDeserializer<Terms
645
692
op .add (Builder ::order ,
646
693
JsonpDeserializer .arrayDeserializer (NamedValue .deserializer (() -> SortOrder ._DESERIALIZER )), "order" );
647
694
op .add (Builder ::script , Script ._DESERIALIZER , "script" );
695
+ op .add (Builder ::shardMinDocCount , JsonpDeserializer .longDeserializer (), "shard_min_doc_count" );
648
696
op .add (Builder ::shardSize , JsonpDeserializer .integerDeserializer (), "shard_size" );
649
697
op .add (Builder ::showTermDocCountError , JsonpDeserializer .booleanDeserializer (), "show_term_doc_count_error" );
650
698
op .add (Builder ::size , JsonpDeserializer .integerDeserializer (), "size" );
0 commit comments