3131import co .elastic .clients .util .WithJsonObjectBuilderBase ;
3232import jakarta .json .stream .JsonGenerator ;
3333import java .lang .Long ;
34+ import java .lang .String ;
3435import java .util .Objects ;
3536import java .util .function .Function ;
3637import javax .annotation .Nullable ;
@@ -64,12 +65,19 @@ public class DocStats implements JsonpSerializable {
6465 @ Nullable
6566 private final Long deleted ;
6667
68+ private final long totalSizeInBytes ;
69+
70+ @ Nullable
71+ private final String totalSize ;
72+
6773 // ---------------------------------------------------------------------------------------------
6874
6975 private DocStats (Builder builder ) {
7076
7177 this .count = ApiTypeHelper .requireNonNull (builder .count , this , "count" , 0 );
7278 this .deleted = builder .deleted ;
79+ this .totalSizeInBytes = ApiTypeHelper .requireNonNull (builder .totalSizeInBytes , this , "totalSizeInBytes" , 0 );
80+ this .totalSize = builder .totalSize ;
7381
7482 }
7583
@@ -101,6 +109,27 @@ public final Long deleted() {
101109 return this .deleted ;
102110 }
103111
112+ /**
113+ * Required - Returns the total size in bytes of all documents in this stats.
114+ * This value may be more reliable than store_stats.size_in_bytes in estimating
115+ * the index size.
116+ * <p>
117+ * API name: {@code total_size_in_bytes}
118+ */
119+ public final long totalSizeInBytes () {
120+ return this .totalSizeInBytes ;
121+ }
122+
123+ /**
124+ * Human readable total_size_in_bytes
125+ * <p>
126+ * API name: {@code total_size}
127+ */
128+ @ Nullable
129+ public final String totalSize () {
130+ return this .totalSize ;
131+ }
132+
104133 /**
105134 * Serialize this object to JSON.
106135 */
@@ -120,6 +149,14 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
120149 generator .write (this .deleted );
121150
122151 }
152+ generator .writeKey ("total_size_in_bytes" );
153+ generator .write (this .totalSizeInBytes );
154+
155+ if (this .totalSize != null ) {
156+ generator .writeKey ("total_size" );
157+ generator .write (this .totalSize );
158+
159+ }
123160
124161 }
125162
@@ -140,6 +177,11 @@ public static class Builder extends WithJsonObjectBuilderBase<Builder> implement
140177 @ Nullable
141178 private Long deleted ;
142179
180+ private Long totalSizeInBytes ;
181+
182+ @ Nullable
183+ private String totalSize ;
184+
143185 /**
144186 * Required - Total number of non-deleted documents across all primary shards
145187 * assigned to selected nodes. This number is based on documents in Lucene
@@ -165,6 +207,28 @@ public final Builder deleted(@Nullable Long value) {
165207 return this ;
166208 }
167209
210+ /**
211+ * Required - Returns the total size in bytes of all documents in this stats.
212+ * This value may be more reliable than store_stats.size_in_bytes in estimating
213+ * the index size.
214+ * <p>
215+ * API name: {@code total_size_in_bytes}
216+ */
217+ public final Builder totalSizeInBytes (long value ) {
218+ this .totalSizeInBytes = value ;
219+ return this ;
220+ }
221+
222+ /**
223+ * Human readable total_size_in_bytes
224+ * <p>
225+ * API name: {@code total_size}
226+ */
227+ public final Builder totalSize (@ Nullable String value ) {
228+ this .totalSize = value ;
229+ return this ;
230+ }
231+
168232 @ Override
169233 protected Builder self () {
170234 return this ;
@@ -195,6 +259,8 @@ protected static void setupDocStatsDeserializer(ObjectDeserializer<DocStats.Buil
195259
196260 op .add (Builder ::count , JsonpDeserializer .longDeserializer (), "count" );
197261 op .add (Builder ::deleted , JsonpDeserializer .longDeserializer (), "deleted" );
262+ op .add (Builder ::totalSizeInBytes , JsonpDeserializer .longDeserializer (), "total_size_in_bytes" );
263+ op .add (Builder ::totalSize , JsonpDeserializer .stringDeserializer (), "total_size" );
198264
199265 }
200266
0 commit comments