@@ -79,6 +79,9 @@ public class DenseVectorIndexOptions implements JsonpSerializable {
7979 @ Nullable
8080 private final Boolean onDiskRescore ;
8181
82+ @ Nullable
83+ private final Integer flatIndexThreshold ;
84+
8285 // ---------------------------------------------------------------------------------------------
8386
8487 private DenseVectorIndexOptions (Builder builder ) {
@@ -89,6 +92,7 @@ private DenseVectorIndexOptions(Builder builder) {
8992 this .type = ApiTypeHelper .requireNonNull (builder .type , this , "type" );
9093 this .rescoreVector = builder .rescoreVector ;
9194 this .onDiskRescore = builder .onDiskRescore ;
95+ this .flatIndexThreshold = builder .flatIndexThreshold ;
9296
9397 }
9498
@@ -183,6 +187,24 @@ public final Boolean onDiskRescore() {
183187 return this .onDiskRescore ;
184188 }
185189
190+ /**
191+ * The segment document count threshold below which HNSW graph construction is
192+ * skipped in favor of brute-force flat search. <code>-1</code> (default) defers
193+ * to format defaults: <code>300</code> for <code>bbq_hnsw</code>,
194+ * <code>150</code> for <code>hnsw</code>, <code>int8_hnsw</code>, and
195+ * <code>int4_hnsw</code>. <code>0</code> always builds the graph. A positive
196+ * value overrides the format default.
197+ * <p>
198+ * Only applicable to <code>hnsw</code>, <code>int8_hnsw</code>,
199+ * <code>int4_hnsw</code>, and <code>bbq_hnsw</code> index types.
200+ * <p>
201+ * API name: {@code flat_index_threshold}
202+ */
203+ @ Nullable
204+ public final Integer flatIndexThreshold () {
205+ return this .flatIndexThreshold ;
206+ }
207+
186208 /**
187209 * Serialize this object to JSON.
188210 */
@@ -221,6 +243,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
221243 generator .write (this .onDiskRescore );
222244
223245 }
246+ if (this .flatIndexThreshold != null ) {
247+ generator .writeKey ("flat_index_threshold" );
248+ generator .write (this .flatIndexThreshold );
249+
250+ }
224251
225252 }
226253
@@ -255,6 +282,9 @@ public static class Builder extends WithJsonObjectBuilderBase<Builder>
255282 @ Nullable
256283 private Boolean onDiskRescore ;
257284
285+ @ Nullable
286+ private Integer flatIndexThreshold ;
287+
258288 public Builder () {
259289 }
260290 private Builder (DenseVectorIndexOptions instance ) {
@@ -264,6 +294,7 @@ private Builder(DenseVectorIndexOptions instance) {
264294 this .type = instance .type ;
265295 this .rescoreVector = instance .rescoreVector ;
266296 this .onDiskRescore = instance .onDiskRescore ;
297+ this .flatIndexThreshold = instance .flatIndexThreshold ;
267298
268299 }
269300 /**
@@ -367,6 +398,24 @@ public final Builder onDiskRescore(@Nullable Boolean value) {
367398 return this ;
368399 }
369400
401+ /**
402+ * The segment document count threshold below which HNSW graph construction is
403+ * skipped in favor of brute-force flat search. <code>-1</code> (default) defers
404+ * to format defaults: <code>300</code> for <code>bbq_hnsw</code>,
405+ * <code>150</code> for <code>hnsw</code>, <code>int8_hnsw</code>, and
406+ * <code>int4_hnsw</code>. <code>0</code> always builds the graph. A positive
407+ * value overrides the format default.
408+ * <p>
409+ * Only applicable to <code>hnsw</code>, <code>int8_hnsw</code>,
410+ * <code>int4_hnsw</code>, and <code>bbq_hnsw</code> index types.
411+ * <p>
412+ * API name: {@code flat_index_threshold}
413+ */
414+ public final Builder flatIndexThreshold (@ Nullable Integer value ) {
415+ this .flatIndexThreshold = value ;
416+ return this ;
417+ }
418+
370419 @ Override
371420 protected Builder self () {
372421 return this ;
@@ -408,6 +457,7 @@ protected static void setupDenseVectorIndexOptionsDeserializer(
408457 op .add (Builder ::type , DenseVectorIndexOptionsType ._DESERIALIZER , "type" );
409458 op .add (Builder ::rescoreVector , DenseVectorIndexOptionsRescoreVector ._DESERIALIZER , "rescore_vector" );
410459 op .add (Builder ::onDiskRescore , JsonpDeserializer .booleanDeserializer (), "on_disk_rescore" );
460+ op .add (Builder ::flatIndexThreshold , JsonpDeserializer .integerDeserializer (), "flat_index_threshold" );
411461
412462 }
413463
0 commit comments