Skip to content

Commit 5dece5a

Browse files
committed
Adding backport index versions for PR elastic#127134 (elastic#127724)
This adds backport index versions in preparation for backporting elastic#127134
1 parent 538adbc commit 5dece5a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ private static IndexVersion def(int id, Version luceneVersion) {
130130
public static final IndexVersion SYNTHETIC_SOURCE_STORE_ARRAYS_NATIVELY = def(8_527_0_00, Version.LUCENE_9_12_1);
131131
public static final IndexVersion ADD_RESCORE_PARAMS_TO_QUANTIZED_VECTORS = def(8_528_0_00, Version.LUCENE_9_12_1);
132132
public static final IndexVersion RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS = def(8_529_0_00, Version.LUCENE_9_12_1);
133+
public static final IndexVersion DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ_BACKPORT_8_X = def(8_530_0_00, Version.LUCENE_9_12_1);
133134
/*
134135
* STOP! READ THIS FIRST! No, really,
135136
* ____ _____ ___ ____ _ ____ _____ _ ____ _____ _ _ ___ ____ _____ ___ ____ ____ _____ _

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

+9-10
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@
9494

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

Comments
 (0)