Skip to content

Commit 7e01db2

Browse files
benwtrentywangd
authored andcommitted
Adding backport index versions for PR elastic#127134 (elastic#127724)
This adds backport index versions in preparation for backporting elastic#127134
1 parent e2b1466 commit 7e01db2

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

server/src/main/java/org/elasticsearch/index/IndexVersions.java

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ private static Version parseUnchecked(String version) {
139139
public static final IndexVersion SYNTHETIC_SOURCE_STORE_ARRAYS_NATIVELY_BACKPORT_8_X = def(8_527_0_00, Version.LUCENE_9_12_1);
140140
public static final IndexVersion ADD_RESCORE_PARAMS_TO_QUANTIZED_VECTORS_BACKPORT_8_X = def(8_528_0_00, Version.LUCENE_9_12_1);
141141
public static final IndexVersion RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS_BACKPORT_8_X = def(8_529_0_00, Version.LUCENE_9_12_1);
142+
public static final IndexVersion DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ_BACKPORT_8_X = def(8_530_0_00, Version.LUCENE_9_12_1);
142143
public static final IndexVersion UPGRADE_TO_LUCENE_10_0_0 = def(9_000_0_00, Version.LUCENE_10_0_0);
143144
public static final IndexVersion LOGSDB_DEFAULT_IGNORE_DYNAMIC_BEYOND_LIMIT = def(9_001_0_00, Version.LUCENE_10_0_0);
144145
public static final IndexVersion TIME_BASED_K_ORDERED_DOC_ID = def(9_002_0_00, Version.LUCENE_10_0_0);

server/src/main/java/org/elasticsearch/index/mapper/vectors/DenseVectorFieldMapper.java

+10-8
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@
9595

9696
import static org.elasticsearch.common.Strings.format;
9797
import 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

Comments
 (0)