9494
9595import static org .elasticsearch .common .Strings .format ;
9696import 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 ;
9997
10098/**
10199 * A {@link FieldMapper} for indexing a dense vector of floats.
@@ -118,17 +116,18 @@ private static boolean hasRescoreIndexVersion(IndexVersion version) {
118116 }
119117
120118 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 );
122124 }
123125
124126 public static final IndexVersion MAGNITUDE_STORED_INDEX_VERSION = IndexVersions .V_7_5_0 ;
125127 public static final IndexVersion INDEXED_BY_DEFAULT_INDEX_VERSION = IndexVersions .FIRST_DETACHED_INDEX_VERSION ;
126128 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 ;
128130 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 ;
132131
133132 public static final NodeFeature RESCORE_VECTOR_QUANTIZED_VECTOR_MAPPING = new NodeFeature ("mapper.dense_vector.rescore_vector" );
134133 public static final NodeFeature RESCORE_ZERO_VECTOR_QUANTIZED_VECTOR_MAPPING = new NodeFeature (
@@ -201,7 +200,7 @@ public Builder(String name, IndexVersion indexVersionCreated) {
201200 super (name );
202201 this .indexVersionCreated = indexVersionCreated ;
203202 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 );
205204 this .indexed = Parameter .indexParam (m -> toType (m ).fieldType ().indexed , indexedByDefault );
206205 if (indexedByDefault ) {
207206 // 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
14441443 RescoreVector rescoreVector = null ;
14451444 if (hasRescoreIndexVersion (indexVersion )) {
14461445 rescoreVector = RescoreVector .fromIndexOptions (indexOptionsMap , indexVersion );
1447- if (rescoreVector == null && indexVersion . onOrAfter ( DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ )) {
1446+ if (rescoreVector == null && defaultOversampleForBBQ ( indexVersion )) {
14481447 rescoreVector = new RescoreVector (DEFAULT_OVERSAMPLE );
14491448 }
14501449 }
@@ -1468,7 +1467,7 @@ public IndexOptions parseIndexOptions(String fieldName, Map<String, ?> indexOpti
14681467 RescoreVector rescoreVector = null ;
14691468 if (hasRescoreIndexVersion (indexVersion )) {
14701469 rescoreVector = RescoreVector .fromIndexOptions (indexOptionsMap , indexVersion );
1471- if (rescoreVector == null && indexVersion . onOrAfter ( DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ )) {
1470+ if (rescoreVector == null && defaultOversampleForBBQ ( indexVersion )) {
14721471 rescoreVector = new RescoreVector (DEFAULT_OVERSAMPLE );
14731472 }
14741473 }
0 commit comments