Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/128291.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 128291
summary: Make `dense_vector` fields updatable to bbq_flat/bbq_hnsw
area: Vector Search
type: enhancement
issues: []
4 changes: 2 additions & 2 deletions docs/reference/mapping/types/dense-vector.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,10 @@ To better accommodate scaling and performance needs, updating the `type` setting

[source,txt]
----
flat --> int8_flat --> int4_flat --> hnsw --> int8_hnsw --> int4_hnsw
flat --> int8_flat --> int4_flat --> bbq_flat --> hnsw --> int8_hnsw --> int4_hnsw --> bbq_hnsw
----

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).
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).

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.common.Strings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.IndexVersions;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentType;

Expand All @@ -31,6 +33,8 @@
*/
public class DenseVectorMappingUpdateIT extends AbstractRollingUpgradeTestCase {

private static final String SYNTHETIC_SOURCE_FEATURE = "gte_v8.12.0";

private static final String BULK1 = """
{"index": {"_id": "1"}}
{"embedding": [1, 1, 1, 1]}
Expand Down Expand Up @@ -86,10 +90,23 @@ public void testDenseVectorMappingUpdateOnOldCluster() throws IOException {
String indexName = "test_index";
if (isOldCluster()) {
Request createIndex = new Request("PUT", "/" + indexName);
XContentBuilder mappings = XContentBuilder.builder(XContentType.JSON.xContent())
.startObject()
.startObject("mappings")
.startObject("properties")
boolean useSyntheticSource = randomBoolean() && oldClusterHasFeature(SYNTHETIC_SOURCE_FEATURE);

IndexVersion version = getOldClusterIndexVersion();
boolean useIndexSetting = version.onOrAfter(IndexVersions.DEPRECATE_SOURCE_MODE_MAPPER);
XContentBuilder payload = XContentBuilder.builder(XContentType.JSON.xContent()).startObject();
if (useSyntheticSource) {
if (useIndexSetting) {
payload.startObject("settings").field("index.mapping.source.mode", "synthetic").endObject();
}
}
payload.startObject("mappings");
if (useIndexSetting == false) {
payload.startObject("_source");
payload.field("mode", "synthetic");
payload.endObject();
}
payload.startObject("properties")
.startObject("embedding")
.field("type", "dense_vector")
.field("index", "true")
Expand All @@ -104,7 +121,7 @@ public void testDenseVectorMappingUpdateOnOldCluster() throws IOException {
.endObject()
.endObject()
.endObject();
createIndex.setJsonEntity(Strings.toString(mappings));
createIndex.setJsonEntity(Strings.toString(payload));
client().performRequest(createIndex);
Request index = new Request("POST", "/" + indexName + "/_bulk/");
index.addParameter("refresh", "true");
Expand Down
Loading