@@ -109,6 +109,11 @@ public static boolean isNotUnitVector(float magnitude) {
109109 return Math .abs (magnitude - 1.0f ) > EPS ;
110110 }
111111
112+ private static boolean hasRescoreIndexVersion (IndexVersion version ) {
113+ return version .onOrAfter (IndexVersions .ADD_RESCORE_PARAMS_TO_QUANTIZED_VECTORS )
114+ || version .between (IndexVersions .ADD_RESCORE_PARAMS_TO_QUANTIZED_VECTORS_BACKPORT_8_X , IndexVersions .UPGRADE_TO_LUCENE_10_0_0 );
115+ }
116+
112117 public static final IndexVersion MAGNITUDE_STORED_INDEX_VERSION = IndexVersions .V_7_5_0 ;
113118 public static final IndexVersion INDEXED_BY_DEFAULT_INDEX_VERSION = IndexVersions .FIRST_DETACHED_INDEX_VERSION ;
114119 public static final IndexVersion NORMALIZE_COSINE = IndexVersions .NORMALIZED_VECTOR_COSINE ;
@@ -1350,7 +1355,7 @@ public IndexOptions parseIndexOptions(String fieldName, Map<String, ?> indexOpti
13501355 confidenceInterval = (float ) XContentMapValues .nodeDoubleValue (confidenceIntervalNode );
13511356 }
13521357 RescoreVector rescoreVector = null ;
1353- if (indexVersion . onOrAfter ( ADD_RESCORE_PARAMS_TO_QUANTIZED_VECTORS )) {
1358+ if (hasRescoreIndexVersion ( indexVersion )) {
13541359 rescoreVector = RescoreVector .fromIndexOptions (indexOptionsMap , indexVersion );
13551360 }
13561361 MappingParser .checkNoRemainingFields (fieldName , indexOptionsMap );
@@ -1385,7 +1390,7 @@ public IndexOptions parseIndexOptions(String fieldName, Map<String, ?> indexOpti
13851390 confidenceInterval = (float ) XContentMapValues .nodeDoubleValue (confidenceIntervalNode );
13861391 }
13871392 RescoreVector rescoreVector = null ;
1388- if (indexVersion . onOrAfter ( ADD_RESCORE_PARAMS_TO_QUANTIZED_VECTORS )) {
1393+ if (hasRescoreIndexVersion ( indexVersion )) {
13891394 rescoreVector = RescoreVector .fromIndexOptions (indexOptionsMap , indexVersion );
13901395 }
13911396 MappingParser .checkNoRemainingFields (fieldName , indexOptionsMap );
@@ -1428,7 +1433,7 @@ public IndexOptions parseIndexOptions(String fieldName, Map<String, ?> indexOpti
14281433 confidenceInterval = (float ) XContentMapValues .nodeDoubleValue (confidenceIntervalNode );
14291434 }
14301435 RescoreVector rescoreVector = null ;
1431- if (indexVersion . onOrAfter ( ADD_RESCORE_PARAMS_TO_QUANTIZED_VECTORS )) {
1436+ if (hasRescoreIndexVersion ( indexVersion )) {
14321437 rescoreVector = RescoreVector .fromIndexOptions (indexOptionsMap , indexVersion );
14331438 }
14341439 MappingParser .checkNoRemainingFields (fieldName , indexOptionsMap );
@@ -1454,7 +1459,7 @@ public IndexOptions parseIndexOptions(String fieldName, Map<String, ?> indexOpti
14541459 confidenceInterval = (float ) XContentMapValues .nodeDoubleValue (confidenceIntervalNode );
14551460 }
14561461 RescoreVector rescoreVector = null ;
1457- if (indexVersion . onOrAfter ( ADD_RESCORE_PARAMS_TO_QUANTIZED_VECTORS )) {
1462+ if (hasRescoreIndexVersion ( indexVersion )) {
14581463 rescoreVector = RescoreVector .fromIndexOptions (indexOptionsMap , indexVersion );
14591464 }
14601465 MappingParser .checkNoRemainingFields (fieldName , indexOptionsMap );
@@ -1485,7 +1490,7 @@ public IndexOptions parseIndexOptions(String fieldName, Map<String, ?> indexOpti
14851490 int m = XContentMapValues .nodeIntegerValue (mNode );
14861491 int efConstruction = XContentMapValues .nodeIntegerValue (efConstructionNode );
14871492 RescoreVector rescoreVector = null ;
1488- if (indexVersion . onOrAfter ( ADD_RESCORE_PARAMS_TO_QUANTIZED_VECTORS )) {
1493+ if (hasRescoreIndexVersion ( indexVersion )) {
14891494 rescoreVector = RescoreVector .fromIndexOptions (indexOptionsMap , indexVersion );
14901495 if (rescoreVector == null && indexVersion .onOrAfter (DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ )) {
14911496 rescoreVector = new RescoreVector (DEFAULT_OVERSAMPLE );
@@ -1509,7 +1514,7 @@ public boolean supportsDimension(int dims) {
15091514 @ Override
15101515 public IndexOptions parseIndexOptions (String fieldName , Map <String , ?> indexOptionsMap , IndexVersion indexVersion ) {
15111516 RescoreVector rescoreVector = null ;
1512- if (indexVersion . onOrAfter ( ADD_RESCORE_PARAMS_TO_QUANTIZED_VECTORS )) {
1517+ if (hasRescoreIndexVersion ( indexVersion )) {
15131518 rescoreVector = RescoreVector .fromIndexOptions (indexOptionsMap , indexVersion );
15141519 if (rescoreVector == null && indexVersion .onOrAfter (DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ )) {
15151520 rescoreVector = new RescoreVector (DEFAULT_OVERSAMPLE );
0 commit comments