Skip to content

Commit d31cc9c

Browse files
committed
Adding versions for bwc for elastic#125599 (elastic#127663)
blocks: elastic#127662 This adds bwc versions for elastic#125599
1 parent cebe253 commit d31cc9c

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ static TransportVersion def(int id) {
211211
public static final TransportVersion ESQL_REPORT_ORIGINAL_TYPES_BACKPORT_8_19 = def(8_841_0_22);
212212
public static final TransportVersion PINNED_RETRIEVER_8_19 = def(8_841_0_23);
213213
public static final TransportVersion ESQL_AGGREGATE_METRIC_DOUBLE_BLOCK_8_19 = def(8_841_0_24);
214-
public static final TransportVersion RESCORE_VECTOR_ALLOW_ZERO_8_19 = def(8_841_0_24);
214+
public static final TransportVersion INTRODUCE_FAILURES_LIFECYCLE_BACKPORT_8_19 = def(8_841_0_25);
215+
public static final TransportVersion INTRODUCE_FAILURES_DEFAULT_RETENTION_BACKPORT_8_19 = def(8_841_0_26);
216+
public static final TransportVersion RESCORE_VECTOR_ALLOW_ZERO_BACKPORT_8_19 = def(8_841_0_27);
215217

216218
/*
217219
* STOP! READ THIS FIRST! No, really,

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
import static org.elasticsearch.common.Strings.format;
9696
import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken;
9797
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;
9899

99100
/**
100101
* A {@link FieldMapper} for indexing a dense vector of floats.
@@ -116,6 +117,10 @@ private static boolean hasRescoreIndexVersion(IndexVersion version) {
116117
return version.onOrAfter(IndexVersions.ADD_RESCORE_PARAMS_TO_QUANTIZED_VECTORS);
117118
}
118119

120+
private static boolean allowsZeroRescore(IndexVersion version) {
121+
return version.onOrAfter(RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS);
122+
}
123+
119124
public static final IndexVersion MAGNITUDE_STORED_INDEX_VERSION = IndexVersions.V_7_5_0;
120125
public static final IndexVersion INDEXED_BY_DEFAULT_INDEX_VERSION = IndexVersions.FIRST_DETACHED_INDEX_VERSION;
121126
public static final IndexVersion NORMALIZE_COSINE = IndexVersions.NORMALIZED_VECTOR_COSINE;
@@ -1979,7 +1984,7 @@ static RescoreVector fromIndexOptions(Map<String, ?> indexOptionsMap, IndexVersi
19791984
throw new IllegalArgumentException("Invalid rescore_vector value. Missing required field " + OVERSAMPLE);
19801985
}
19811986
float oversampleValue = (float) XContentMapValues.nodeDoubleValue(oversampleNode);
1982-
if (oversampleValue == 0 && indexVersion.before(RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS)) {
1987+
if (oversampleValue == 0 && allowsZeroRescore(indexVersion) == false) {
19831988
throw new IllegalArgumentException("oversample must be greater than 1");
19841989
}
19851990
if (oversampleValue < 1 && oversampleValue != 0) {

server/src/main/java/org/elasticsearch/search/vectors/RescoreVectorBuilder.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.Objects;
2525

2626
import static org.elasticsearch.TransportVersions.RESCORE_VECTOR_ALLOW_ZERO;
27+
import static org.elasticsearch.TransportVersions.RESCORE_VECTOR_ALLOW_ZERO_BACKPORT_8_19;
2728

2829
public class RescoreVectorBuilder implements Writeable, ToXContentObject {
2930

@@ -57,12 +58,13 @@ public RescoreVectorBuilder(StreamInput in) throws IOException {
5758
@Override
5859
public void writeTo(StreamOutput out) throws IOException {
5960
// We don't want to serialize a `0` oversample to a node that doesn't know what to do with it.
60-
if (oversample == NO_OVERSAMPLE && out.getTransportVersion().before(RESCORE_VECTOR_ALLOW_ZERO)) {
61+
if (oversample == NO_OVERSAMPLE
62+
&& out.getTransportVersion().isPatchFrom(RESCORE_VECTOR_ALLOW_ZERO_BACKPORT_8_19) == false) {
6163
throw new ElasticsearchStatusException(
6264
"[rescore_vector] does not support a 0 for ["
6365
+ OVERSAMPLE_FIELD.getPreferredName()
6466
+ "] before version ["
65-
+ RESCORE_VECTOR_ALLOW_ZERO.toReleaseVersion()
67+
+ RESCORE_VECTOR_ALLOW_ZERO_BACKPORT_8_19.toReleaseVersion()
6668
+ "]",
6769
RestStatus.BAD_REQUEST
6870
);

server/src/test/java/org/elasticsearch/index/mapper/vectors/DenseVectorFieldMapperTests.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -928,10 +928,17 @@ public void testRescoreVectorOldIndexVersion() {
928928
}
929929

930930
public void testRescoreZeroVectorOldIndexVersion() {
931-
IndexVersion incompatibleVersion = IndexVersionUtils.randomVersionBetween(
932-
random(),
933-
IndexVersionUtils.getLowestReadCompatibleVersion(),
934-
IndexVersionUtils.getPreviousVersion(DenseVectorFieldMapper.RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS)
931+
IndexVersion incompatibleVersion = randomFrom(
932+
IndexVersionUtils.randomVersionBetween(
933+
random(),
934+
IndexVersionUtils.getLowestReadCompatibleVersion(),
935+
IndexVersionUtils.getPreviousVersion(IndexVersions.RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS_BACKPORT_8_X)
936+
),
937+
IndexVersionUtils.randomVersionBetween(
938+
random(),
939+
IndexVersions.UPGRADE_TO_LUCENE_10_0_0,
940+
IndexVersionUtils.getPreviousVersion(IndexVersions.RESCORE_PARAMS_ALLOW_ZERO_TO_QUANTIZED_VECTORS)
941+
)
935942
);
936943
for (String indexType : List.of("int8_hnsw", "int8_flat", "int4_hnsw", "int4_flat", "bbq_hnsw", "bbq_flat")) {
937944
expectThrows(

0 commit comments

Comments
 (0)