9595
9696import static org .elasticsearch .common .Strings .format ;
9797import static org .elasticsearch .common .xcontent .XContentParserUtils .ensureExpectedToken ;
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 ;
10098
10199/**
102100 * A {@link FieldMapper} for indexing a dense vector of floats.
@@ -116,19 +114,23 @@ private static boolean hasRescoreIndexVersion(IndexVersion version) {
116114 }
117115
118116 private static boolean allowsZeroRescore (IndexVersion version ) {
119- return version .onOrAfter (RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS )
117+ return version .onOrAfter (IndexVersions . RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS )
120118 || version .between (
121119 IndexVersions .RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS_BACKPORT_8_X ,
122120 IndexVersions .UPGRADE_TO_LUCENE_10_0_0
123121 );
124122 }
125123
124+ private static boolean defaultOversampleForBBQ (IndexVersion version ) {
125+ return version .onOrAfter (IndexVersions .DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ )
126+ || version .between (IndexVersions .DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ_BACKPORT_8_X , IndexVersions .UPGRADE_TO_LUCENE_10_0_0 );
127+ }
128+
126129 public static final IndexVersion MAGNITUDE_STORED_INDEX_VERSION = IndexVersions .V_7_5_0 ;
127130 public static final IndexVersion INDEXED_BY_DEFAULT_INDEX_VERSION = IndexVersions .FIRST_DETACHED_INDEX_VERSION ;
128131 public static final IndexVersion NORMALIZE_COSINE = IndexVersions .NORMALIZED_VECTOR_COSINE ;
129- public static final IndexVersion DEFAULT_TO_INT8 = DEFAULT_DENSE_VECTOR_TO_INT8_HNSW ;
132+ public static final IndexVersion DEFAULT_TO_INT8 = IndexVersions . DEFAULT_DENSE_VECTOR_TO_INT8_HNSW ;
130133 public static final IndexVersion LITTLE_ENDIAN_FLOAT_STORED_INDEX_VERSION = IndexVersions .V_8_9_0 ;
131- public static final IndexVersion DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ = IndexVersions .DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ ;
132134
133135 public static final NodeFeature RESCORE_VECTOR_QUANTIZED_VECTOR_MAPPING = new NodeFeature ("mapper.dense_vector.rescore_vector" );
134136 public static final NodeFeature RESCORE_ZERO_VECTOR_QUANTIZED_VECTOR_MAPPING = new NodeFeature (
@@ -202,7 +204,7 @@ public Builder(String name, IndexVersion indexVersionCreated) {
202204 super (name );
203205 this .indexVersionCreated = indexVersionCreated ;
204206 final boolean indexedByDefault = indexVersionCreated .onOrAfter (INDEXED_BY_DEFAULT_INDEX_VERSION );
205- final boolean defaultInt8Hnsw = indexVersionCreated .onOrAfter (DEFAULT_DENSE_VECTOR_TO_INT8_HNSW );
207+ final boolean defaultInt8Hnsw = indexVersionCreated .onOrAfter (IndexVersions . DEFAULT_DENSE_VECTOR_TO_INT8_HNSW );
206208 this .indexed = Parameter .indexParam (m -> toType (m ).fieldType ().indexed , indexedByDefault );
207209 if (indexedByDefault ) {
208210 // Only serialize on newer index versions to prevent breaking existing indices when upgrading
@@ -1498,7 +1500,7 @@ public IndexOptions parseIndexOptions(String fieldName, Map<String, ?> indexOpti
14981500 RescoreVector rescoreVector = null ;
14991501 if (hasRescoreIndexVersion (indexVersion )) {
15001502 rescoreVector = RescoreVector .fromIndexOptions (indexOptionsMap , indexVersion );
1501- if (rescoreVector == null && indexVersion . onOrAfter ( DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ )) {
1503+ if (rescoreVector == null && defaultOversampleForBBQ ( indexVersion )) {
15021504 rescoreVector = new RescoreVector (DEFAULT_OVERSAMPLE );
15031505 }
15041506 }
@@ -1522,7 +1524,7 @@ public IndexOptions parseIndexOptions(String fieldName, Map<String, ?> indexOpti
15221524 RescoreVector rescoreVector = null ;
15231525 if (hasRescoreIndexVersion (indexVersion )) {
15241526 rescoreVector = RescoreVector .fromIndexOptions (indexOptionsMap , indexVersion );
1525- if (rescoreVector == null && indexVersion . onOrAfter ( DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ )) {
1527+ if (rescoreVector == null && defaultOversampleForBBQ ( indexVersion )) {
15261528 rescoreVector = new RescoreVector (DEFAULT_OVERSAMPLE );
15271529 }
15281530 }
0 commit comments