9696import static org .elasticsearch .common .Strings .format ;
9797import static org .elasticsearch .common .xcontent .XContentParserUtils .ensureExpectedToken ;
9898import static org .elasticsearch .index .IndexVersions .DEFAULT_DENSE_VECTOR_TO_INT8_HNSW ;
99+ import static org .elasticsearch .index .IndexVersions .RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS ;
99100
100101/**
101102 * A {@link FieldMapper} for indexing a dense vector of floats.
@@ -114,14 +115,19 @@ private static boolean hasRescoreIndexVersion(IndexVersion version) {
114115 || version .between (IndexVersions .ADD_RESCORE_PARAMS_TO_QUANTIZED_VECTORS_BACKPORT_8_X , IndexVersions .UPGRADE_TO_LUCENE_10_0_0 );
115116 }
116117
118+ private static boolean allowsZeroRescore (IndexVersion version ) {
119+ return version .onOrAfter (RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS )
120+ || version .between (
121+ IndexVersions .RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS_BACKPORT_8_X ,
122+ IndexVersions .UPGRADE_TO_LUCENE_10_0_0
123+ );
124+ }
125+
117126 public static final IndexVersion MAGNITUDE_STORED_INDEX_VERSION = IndexVersions .V_7_5_0 ;
118127 public static final IndexVersion INDEXED_BY_DEFAULT_INDEX_VERSION = IndexVersions .FIRST_DETACHED_INDEX_VERSION ;
119128 public static final IndexVersion NORMALIZE_COSINE = IndexVersions .NORMALIZED_VECTOR_COSINE ;
120129 public static final IndexVersion DEFAULT_TO_INT8 = DEFAULT_DENSE_VECTOR_TO_INT8_HNSW ;
121130 public static final IndexVersion LITTLE_ENDIAN_FLOAT_STORED_INDEX_VERSION = IndexVersions .V_8_9_0 ;
122- public static final IndexVersion ADD_RESCORE_PARAMS_TO_QUANTIZED_VECTORS = IndexVersions .ADD_RESCORE_PARAMS_TO_QUANTIZED_VECTORS ;
123- public static final IndexVersion RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS =
124- IndexVersions .RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS ;
125131 public static final IndexVersion DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ = IndexVersions .DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ ;
126132
127133 public static final NodeFeature RESCORE_VECTOR_QUANTIZED_VECTOR_MAPPING = new NodeFeature ("mapper.dense_vector.rescore_vector" );
@@ -2050,7 +2056,7 @@ static RescoreVector fromIndexOptions(Map<String, ?> indexOptionsMap, IndexVersi
20502056 throw new IllegalArgumentException ("Invalid rescore_vector value. Missing required field " + OVERSAMPLE );
20512057 }
20522058 float oversampleValue = (float ) XContentMapValues .nodeDoubleValue (oversampleNode );
2053- if (oversampleValue == 0 && indexVersion . before ( RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS )) {
2059+ if (oversampleValue == 0 && allowsZeroRescore ( indexVersion )) {
20542060 throw new IllegalArgumentException ("oversample must be greater than 1" );
20552061 }
20562062 if (oversampleValue < 1 && oversampleValue != 0 ) {
0 commit comments