Skip to content

Commit cf4e47f

Browse files
authored
[8.19] Make dense_vector fields updatable to bbq_flat/bbq_hnsw (#128291) (#129495)
1 parent 12411fd commit cf4e47f

File tree

7 files changed

+875
-15
lines changed

7 files changed

+875
-15
lines changed

docs/changelog/128291.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 128291
2+
summary: Make `dense_vector` fields updatable to bbq_flat/bbq_hnsw
3+
area: Vector Search
4+
type: enhancement
5+
issues: []

docs/reference/mapping/types/dense-vector.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,10 +476,10 @@ To better accommodate scaling and performance needs, updating the `type` setting
476476

477477
[source,txt]
478478
----
479-
flat --> int8_flat --> int4_flat --> hnsw --> int8_hnsw --> int4_hnsw
479+
flat --> int8_flat --> int4_flat --> bbq_flat --> hnsw --> int8_hnsw --> int4_hnsw --> bbq_hnsw
480480
----
481481

482-
For updating all HNSW types (`hnsw`, `int8_hnsw`, `int4_hnsw`) the number of connections `m` must either stay the same or increase. For scalar quantized formats (`int8_flat`, `int4_flat`, `int8_hnsw`, `int4_hnsw`) the `confidence_interval` must always be consistent (once defined, it cannot change).
482+
For updating all HNSW types (`hnsw`, `int8_hnsw`, `int4_hnsw`, `bbq_hnsw`) the number of connections `m` must either stay the same or increase. For the scalar quantized formats `int8_flat`, `int4_flat`, `int8_hnsw` and `int4_hnsw` the `confidence_interval` must always be consistent (once defined, it cannot change).
483483

484484
Updating `type` in `index_options` will fail in all other scenarios.
485485

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DenseVectorMappingUpdateIT.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import org.elasticsearch.client.Request;
1616
import org.elasticsearch.client.Response;
1717
import org.elasticsearch.common.Strings;
18+
import org.elasticsearch.index.IndexVersion;
19+
import org.elasticsearch.index.IndexVersions;
1820
import org.elasticsearch.xcontent.XContentBuilder;
1921
import org.elasticsearch.xcontent.XContentType;
2022

@@ -31,6 +33,8 @@
3133
*/
3234
public class DenseVectorMappingUpdateIT extends AbstractRollingUpgradeTestCase {
3335

36+
private static final String SYNTHETIC_SOURCE_FEATURE = "gte_v8.12.0";
37+
3438
private static final String BULK1 = """
3539
{"index": {"_id": "1"}}
3640
{"embedding": [1, 1, 1, 1]}
@@ -86,10 +90,23 @@ public void testDenseVectorMappingUpdateOnOldCluster() throws IOException {
8690
String indexName = "test_index";
8791
if (isOldCluster()) {
8892
Request createIndex = new Request("PUT", "/" + indexName);
89-
XContentBuilder mappings = XContentBuilder.builder(XContentType.JSON.xContent())
90-
.startObject()
91-
.startObject("mappings")
92-
.startObject("properties")
93+
boolean useSyntheticSource = randomBoolean() && oldClusterHasFeature(SYNTHETIC_SOURCE_FEATURE);
94+
95+
IndexVersion version = getOldClusterIndexVersion();
96+
boolean useIndexSetting = version.onOrAfter(IndexVersions.DEPRECATE_SOURCE_MODE_MAPPER);
97+
XContentBuilder payload = XContentBuilder.builder(XContentType.JSON.xContent()).startObject();
98+
if (useSyntheticSource) {
99+
if (useIndexSetting) {
100+
payload.startObject("settings").field("index.mapping.source.mode", "synthetic").endObject();
101+
}
102+
}
103+
payload.startObject("mappings");
104+
if (useIndexSetting == false) {
105+
payload.startObject("_source");
106+
payload.field("mode", "synthetic");
107+
payload.endObject();
108+
}
109+
payload.startObject("properties")
93110
.startObject("embedding")
94111
.field("type", "dense_vector")
95112
.field("index", "true")
@@ -104,7 +121,7 @@ public void testDenseVectorMappingUpdateOnOldCluster() throws IOException {
104121
.endObject()
105122
.endObject()
106123
.endObject();
107-
createIndex.setJsonEntity(Strings.toString(mappings));
124+
createIndex.setJsonEntity(Strings.toString(payload));
108125
client().performRequest(createIndex);
109126
Request index = new Request("POST", "/" + indexName + "/_bulk/");
110127
index.addParameter("refresh", "true");

0 commit comments

Comments
 (0)