96
96
import static org .elasticsearch .common .Strings .format ;
97
97
import static org .elasticsearch .common .xcontent .XContentParserUtils .ensureExpectedToken ;
98
98
import 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 ;
99
100
100
101
/**
101
102
* A {@link FieldMapper} for indexing a dense vector of floats.
@@ -114,14 +115,19 @@ private static boolean hasRescoreIndexVersion(IndexVersion version) {
114
115
|| version .between (IndexVersions .ADD_RESCORE_PARAMS_TO_QUANTIZED_VECTORS_BACKPORT_8_X , IndexVersions .UPGRADE_TO_LUCENE_10_0_0 );
115
116
}
116
117
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
+
117
126
public static final IndexVersion MAGNITUDE_STORED_INDEX_VERSION = IndexVersions .V_7_5_0 ;
118
127
public static final IndexVersion INDEXED_BY_DEFAULT_INDEX_VERSION = IndexVersions .FIRST_DETACHED_INDEX_VERSION ;
119
128
public static final IndexVersion NORMALIZE_COSINE = IndexVersions .NORMALIZED_VECTOR_COSINE ;
120
129
public static final IndexVersion DEFAULT_TO_INT8 = DEFAULT_DENSE_VECTOR_TO_INT8_HNSW ;
121
130
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 ;
125
131
public static final IndexVersion DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ = IndexVersions .DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ ;
126
132
127
133
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
2050
2056
throw new IllegalArgumentException ("Invalid rescore_vector value. Missing required field " + OVERSAMPLE );
2051
2057
}
2052
2058
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 ) == false ) {
2054
2060
throw new IllegalArgumentException ("oversample must be greater than 1" );
2055
2061
}
2056
2062
if (oversampleValue < 1 && oversampleValue != 0 ) {
0 commit comments