94
94
95
95
import static org .elasticsearch .common .Strings .format ;
96
96
import static org .elasticsearch .common .xcontent .XContentParserUtils .ensureExpectedToken ;
97
- import static org .elasticsearch .index .IndexVersions .DEFAULT_DENSE_VECTOR_TO_INT8_HNSW ;
98
- import static org .elasticsearch .index .IndexVersions .RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS ;
99
97
100
98
/**
101
99
* A {@link FieldMapper} for indexing a dense vector of floats.
@@ -118,17 +116,18 @@ private static boolean hasRescoreIndexVersion(IndexVersion version) {
118
116
}
119
117
120
118
private static boolean allowsZeroRescore (IndexVersion version ) {
121
- return version .onOrAfter (RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS );
119
+ return version .onOrAfter (IndexVersions .RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS );
120
+ }
121
+
122
+ private static boolean defaultOversampleForBBQ (IndexVersion version ) {
123
+ return version .onOrAfter (IndexVersions .DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ_BACKPORT_8_X );
122
124
}
123
125
124
126
public static final IndexVersion MAGNITUDE_STORED_INDEX_VERSION = IndexVersions .V_7_5_0 ;
125
127
public static final IndexVersion INDEXED_BY_DEFAULT_INDEX_VERSION = IndexVersions .FIRST_DETACHED_INDEX_VERSION ;
126
128
public static final IndexVersion NORMALIZE_COSINE = IndexVersions .NORMALIZED_VECTOR_COSINE ;
127
- public static final IndexVersion DEFAULT_TO_INT8 = DEFAULT_DENSE_VECTOR_TO_INT8_HNSW ;
129
+ public static final IndexVersion DEFAULT_TO_INT8 = IndexVersions . DEFAULT_DENSE_VECTOR_TO_INT8_HNSW ;
128
130
public static final IndexVersion LITTLE_ENDIAN_FLOAT_STORED_INDEX_VERSION = IndexVersions .V_8_9_0 ;
129
- public static final IndexVersion RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS =
130
- IndexVersions .RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS ;
131
- public static final IndexVersion DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ = IndexVersions .DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ ;
132
131
133
132
public static final NodeFeature RESCORE_VECTOR_QUANTIZED_VECTOR_MAPPING = new NodeFeature ("mapper.dense_vector.rescore_vector" );
134
133
public static final NodeFeature RESCORE_ZERO_VECTOR_QUANTIZED_VECTOR_MAPPING = new NodeFeature (
@@ -201,7 +200,7 @@ public Builder(String name, IndexVersion indexVersionCreated) {
201
200
super (name );
202
201
this .indexVersionCreated = indexVersionCreated ;
203
202
final boolean indexedByDefault = indexVersionCreated .onOrAfter (INDEXED_BY_DEFAULT_INDEX_VERSION );
204
- final boolean defaultInt8Hnsw = indexVersionCreated .onOrAfter (DEFAULT_DENSE_VECTOR_TO_INT8_HNSW );
203
+ final boolean defaultInt8Hnsw = indexVersionCreated .onOrAfter (IndexVersions . DEFAULT_DENSE_VECTOR_TO_INT8_HNSW );
205
204
this .indexed = Parameter .indexParam (m -> toType (m ).fieldType ().indexed , indexedByDefault );
206
205
if (indexedByDefault ) {
207
206
// Only serialize on newer index versions to prevent breaking existing indices when upgrading
@@ -1444,7 +1443,7 @@ public IndexOptions parseIndexOptions(String fieldName, Map<String, ?> indexOpti
1444
1443
RescoreVector rescoreVector = null ;
1445
1444
if (hasRescoreIndexVersion (indexVersion )) {
1446
1445
rescoreVector = RescoreVector .fromIndexOptions (indexOptionsMap , indexVersion );
1447
- if (rescoreVector == null && indexVersion . onOrAfter ( DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ )) {
1446
+ if (rescoreVector == null && defaultOversampleForBBQ ( indexVersion )) {
1448
1447
rescoreVector = new RescoreVector (DEFAULT_OVERSAMPLE );
1449
1448
}
1450
1449
}
@@ -1468,7 +1467,7 @@ public IndexOptions parseIndexOptions(String fieldName, Map<String, ?> indexOpti
1468
1467
RescoreVector rescoreVector = null ;
1469
1468
if (hasRescoreIndexVersion (indexVersion )) {
1470
1469
rescoreVector = RescoreVector .fromIndexOptions (indexOptionsMap , indexVersion );
1471
- if (rescoreVector == null && indexVersion . onOrAfter ( DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ )) {
1470
+ if (rescoreVector == null && defaultOversampleForBBQ ( indexVersion )) {
1472
1471
rescoreVector = new RescoreVector (DEFAULT_OVERSAMPLE );
1473
1472
}
1474
1473
}
0 commit comments