@@ -398,6 +398,7 @@ private DenseVectorIndexOptions defaultIndexOptions(boolean defaultInt8Hnsw, boo
398398 return new Int8HnswIndexOptions (
399399 Lucene99HnswVectorsFormat .DEFAULT_MAX_CONN ,
400400 Lucene99HnswVectorsFormat .DEFAULT_BEAM_WIDTH ,
401+ null ,
401402 false ,
402403 null
403404 );
@@ -1349,20 +1350,23 @@ public boolean supportsDimension(int dims) {
13491350 public DenseVectorIndexOptions parseIndexOptions (String fieldName , Map <String , ?> indexOptionsMap , IndexVersion indexVersion ) {
13501351 Object mNode = indexOptionsMap .remove ("m" );
13511352 Object efConstructionNode = indexOptionsMap .remove ("ef_construction" );
1352- // BWC option, ignore
1353- indexOptionsMap .remove ("confidence_interval" );
1353+ Object confidenceIntervalNode = indexOptionsMap .remove ("confidence_interval" );
13541354 Object onDiskRescoreNode = indexOptionsMap .remove ("on_disk_rescore" );
13551355
13561356 int m = XContentMapValues .nodeIntegerValue (mNode , Lucene99HnswVectorsFormat .DEFAULT_MAX_CONN );
13571357 int efConstruction = XContentMapValues .nodeIntegerValue (efConstructionNode , Lucene99HnswVectorsFormat .DEFAULT_BEAM_WIDTH );
13581358 boolean onDiskRescore = XContentMapValues .nodeBooleanValue (onDiskRescoreNode , false );
1359+ Float confidenceInterval = null ;
1360+ if (confidenceIntervalNode != null ) {
1361+ confidenceInterval = (float ) XContentMapValues .nodeDoubleValue (confidenceIntervalNode );
1362+ }
13591363 RescoreVector rescoreVector = null ;
13601364 if (hasRescoreIndexVersion (indexVersion )) {
13611365 rescoreVector = RescoreVector .fromIndexOptions (indexOptionsMap , indexVersion );
13621366 }
13631367 MappingParser .checkNoRemainingFields (fieldName , indexOptionsMap );
13641368
1365- return new Int8HnswIndexOptions (m , efConstruction , onDiskRescore , rescoreVector );
1369+ return new Int8HnswIndexOptions (m , efConstruction , confidenceInterval , onDiskRescore , rescoreVector );
13661370 }
13671371
13681372 @ Override
@@ -1379,20 +1383,23 @@ public boolean supportsDimension(int dims) {
13791383 public DenseVectorIndexOptions parseIndexOptions (String fieldName , Map <String , ?> indexOptionsMap , IndexVersion indexVersion ) {
13801384 Object mNode = indexOptionsMap .remove ("m" );
13811385 Object efConstructionNode = indexOptionsMap .remove ("ef_construction" );
1382- // BWC option, ignore
1383- indexOptionsMap .remove ("confidence_interval" );
1386+ Object confidenceIntervalNode = indexOptionsMap .remove ("confidence_interval" );
13841387 Object onDiskRescoreNode = indexOptionsMap .remove ("on_disk_rescore" );
13851388
13861389 int m = XContentMapValues .nodeIntegerValue (mNode , Lucene99HnswVectorsFormat .DEFAULT_MAX_CONN );
13871390 int efConstruction = XContentMapValues .nodeIntegerValue (efConstructionNode , Lucene99HnswVectorsFormat .DEFAULT_BEAM_WIDTH );
1391+ Float confidenceInterval = null ;
1392+ if (confidenceIntervalNode != null ) {
1393+ confidenceInterval = (float ) XContentMapValues .nodeDoubleValue (confidenceIntervalNode );
1394+ }
13881395 boolean onDiskRescore = XContentMapValues .nodeBooleanValue (onDiskRescoreNode , false );
13891396 RescoreVector rescoreVector = null ;
13901397 if (hasRescoreIndexVersion (indexVersion )) {
13911398 rescoreVector = RescoreVector .fromIndexOptions (indexOptionsMap , indexVersion );
13921399 }
13931400 MappingParser .checkNoRemainingFields (fieldName , indexOptionsMap );
13941401
1395- return new Int4HnswIndexOptions (m , efConstruction , onDiskRescore , rescoreVector );
1402+ return new Int4HnswIndexOptions (m , efConstruction , confidenceInterval , onDiskRescore , rescoreVector );
13961403 }
13971404
13981405 @ Override
@@ -1425,14 +1432,17 @@ public boolean supportsDimension(int dims) {
14251432 INT8_FLAT ("int8_flat" , true ) {
14261433 @ Override
14271434 public DenseVectorIndexOptions parseIndexOptions (String fieldName , Map <String , ?> indexOptionsMap , IndexVersion indexVersion ) {
1428- // BWC option, ignore
1429- indexOptionsMap .remove ("confidence_interval" );
1435+ Object confidenceIntervalNode = indexOptionsMap .remove ("confidence_interval" );
1436+ Float confidenceInterval = null ;
1437+ if (confidenceIntervalNode != null ) {
1438+ confidenceInterval = (float ) XContentMapValues .nodeDoubleValue (confidenceIntervalNode );
1439+ }
14301440 RescoreVector rescoreVector = null ;
14311441 if (hasRescoreIndexVersion (indexVersion )) {
14321442 rescoreVector = RescoreVector .fromIndexOptions (indexOptionsMap , indexVersion );
14331443 }
14341444 MappingParser .checkNoRemainingFields (fieldName , indexOptionsMap );
1435- return new Int8FlatIndexOptions (rescoreVector );
1445+ return new Int8FlatIndexOptions (confidenceInterval , rescoreVector );
14361446 }
14371447
14381448 @ Override
@@ -1448,14 +1458,17 @@ public boolean supportsDimension(int dims) {
14481458 INT4_FLAT ("int4_flat" , true ) {
14491459 @ Override
14501460 public DenseVectorIndexOptions parseIndexOptions (String fieldName , Map <String , ?> indexOptionsMap , IndexVersion indexVersion ) {
1451- // BWC option, ignore
1452- indexOptionsMap .remove ("confidence_interval" );
1461+ Object confidenceIntervalNode = indexOptionsMap .remove ("confidence_interval" );
1462+ Float confidenceInterval = null ;
1463+ if (confidenceIntervalNode != null ) {
1464+ confidenceInterval = (float ) XContentMapValues .nodeDoubleValue (confidenceIntervalNode );
1465+ }
14531466 RescoreVector rescoreVector = null ;
14541467 if (hasRescoreIndexVersion (indexVersion )) {
14551468 rescoreVector = RescoreVector .fromIndexOptions (indexOptionsMap , indexVersion );
14561469 }
14571470 MappingParser .checkNoRemainingFields (fieldName , indexOptionsMap );
1458- return new Int4FlatIndexOptions (rescoreVector );
1471+ return new Int4FlatIndexOptions (confidenceInterval , rescoreVector );
14591472 }
14601473
14611474 @ Override
@@ -1619,15 +1632,20 @@ public String toString() {
16191632 }
16201633
16211634 static class Int8FlatIndexOptions extends QuantizedIndexOptions {
1635+ private final Float confidenceInterval ;
16221636
1623- Int8FlatIndexOptions (RescoreVector rescoreVector ) {
1637+ Int8FlatIndexOptions (Float confidenceInterval , RescoreVector rescoreVector ) {
16241638 super (VectorIndexType .INT8_FLAT , rescoreVector );
1639+ this .confidenceInterval = confidenceInterval ;
16251640 }
16261641
16271642 @ Override
16281643 public XContentBuilder toXContent (XContentBuilder builder , Params params ) throws IOException {
16291644 builder .startObject ();
16301645 builder .field ("type" , type );
1646+ if (confidenceInterval != null ) {
1647+ builder .field ("confidence_interval" , confidenceInterval );
1648+ }
16311649 if (rescoreVector != null ) {
16321650 rescoreVector .toXContent (builder , params );
16331651 }
@@ -1716,12 +1734,20 @@ public boolean isFlat() {
17161734 public static class Int4HnswIndexOptions extends QuantizedIndexOptions {
17171735 private final int m ;
17181736 private final int efConstruction ;
1737+ private final float confidenceInterval ;
17191738 private final boolean onDiskRescore ;
17201739
1721- public Int4HnswIndexOptions (int m , int efConstruction , boolean onDiskRescore , RescoreVector rescoreVector ) {
1740+ public Int4HnswIndexOptions (
1741+ int m ,
1742+ int efConstruction ,
1743+ Float confidenceInterval ,
1744+ boolean onDiskRescore ,
1745+ RescoreVector rescoreVector
1746+ ) {
17221747 super (VectorIndexType .INT4_HNSW , rescoreVector );
17231748 this .m = m ;
17241749 this .efConstruction = efConstruction ;
1750+ this .confidenceInterval = confidenceInterval == null ? 0f : confidenceInterval ;
17251751 this .onDiskRescore = onDiskRescore ;
17261752 }
17271753
@@ -1743,6 +1769,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
17431769 builder .field ("type" , type );
17441770 builder .field ("m" , m );
17451771 builder .field ("ef_construction" , efConstruction );
1772+ builder .field ("confidence_interval" , confidenceInterval );
17461773 if (onDiskRescore ) {
17471774 builder .field ("on_disk_rescore" , true );
17481775 }
@@ -1802,8 +1829,11 @@ public boolean updatableTo(DenseVectorIndexOptions update) {
18021829 }
18031830
18041831 static class Int4FlatIndexOptions extends QuantizedIndexOptions {
1805- Int4FlatIndexOptions (RescoreVector rescoreVector ) {
1832+ private final float confidenceInterval ;
1833+
1834+ Int4FlatIndexOptions (Float confidenceInterval , RescoreVector rescoreVector ) {
18061835 super (VectorIndexType .INT4_FLAT , rescoreVector );
1836+ this .confidenceInterval = confidenceInterval == null ? 0f : confidenceInterval ;
18071837 }
18081838
18091839 @ Override
@@ -1816,6 +1846,7 @@ public KnnVectorsFormat getVectorsFormat(ElementType elementType) {
18161846 public XContentBuilder toXContent (XContentBuilder builder , Params params ) throws IOException {
18171847 builder .startObject ();
18181848 builder .field ("type" , type );
1849+ builder .field ("confidence_interval" , confidenceInterval );
18191850 if (rescoreVector != null ) {
18201851 rescoreVector .toXContent (builder , params );
18211852 }
@@ -1862,12 +1893,20 @@ public boolean updatableTo(DenseVectorIndexOptions update) {
18621893 public static class Int8HnswIndexOptions extends QuantizedIndexOptions {
18631894 private final int m ;
18641895 private final int efConstruction ;
1896+ private final Float confidenceInterval ;
18651897 private final boolean onDiskRescore ;
18661898
1867- public Int8HnswIndexOptions (int m , int efConstruction , boolean onDiskRescore , RescoreVector rescoreVector ) {
1899+ public Int8HnswIndexOptions (
1900+ int m ,
1901+ int efConstruction ,
1902+ Float confidenceInterval ,
1903+ boolean onDiskRescore ,
1904+ RescoreVector rescoreVector
1905+ ) {
18681906 super (VectorIndexType .INT8_HNSW , rescoreVector );
18691907 this .m = m ;
18701908 this .efConstruction = efConstruction ;
1909+ this .confidenceInterval = confidenceInterval ;
18711910 this .onDiskRescore = onDiskRescore ;
18721911 }
18731912
@@ -1889,6 +1928,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
18891928 builder .field ("type" , type );
18901929 builder .field ("m" , m );
18911930 builder .field ("ef_construction" , efConstruction );
1931+ if (confidenceInterval != null ) {
1932+ builder .field ("confidence_interval" , confidenceInterval );
1933+ }
18921934 if (onDiskRescore ) {
18931935 builder .field ("on_disk_rescore" , true );
18941936 }
0 commit comments