From fbd36dd7adf617e6cee21f30a0d8739e9d07699e Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Wed, 8 Apr 2026 13:52:05 +0200 Subject: [PATCH] feat(config): support dropping vector index --- .github/workflows/test.yaml | 3 ++- .../java/io/weaviate/containers/Weaviate.java | 3 ++- .../integration/CollectionsITest.java | 25 +++++++++++++++++++ .../v1/api/collections/VectorConfig.java | 7 +++++- .../v1/api/collections/VectorIndex.java | 18 +++++++++++-- .../config/DeleteVectorIndexRequest.java | 13 ++++++++++ .../config/WeaviateConfigClient.java | 6 +++++ .../config/WeaviateConfigClientAsync.java | 6 +++++ 8 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 src/main/java/io/weaviate/client6/v1/api/collections/config/DeleteVectorIndexRequest.java diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 23099c45c..4bd1c5569 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -91,7 +91,8 @@ jobs: strategy: fail-fast: false matrix: - WEAVIATE_VERSION: ["1.32.24", "1.33.11", "1.34.7", "1.35.2", "1.36.1"] + WEAVIATE_VERSION: + ["1.32.24", "1.33.11", "1.34.7", "1.35.2", "1.36.9", "1.37.0-rc.0"] steps: - uses: actions/checkout@v4 diff --git a/src/it/java/io/weaviate/containers/Weaviate.java b/src/it/java/io/weaviate/containers/Weaviate.java index f7f444afb..f0730fb4d 100644 --- a/src/it/java/io/weaviate/containers/Weaviate.java +++ b/src/it/java/io/weaviate/containers/Weaviate.java @@ -44,7 +44,8 @@ public enum Version { V133(1, 33, 11), V134(1, 34, 7), V135(1, 35, 2), - V136(1, 36, 1); + V136(1, 36, 9), + V137(1, 37, "0-rc.0"); public final SemanticVersion semver; diff --git a/src/it/java/io/weaviate/integration/CollectionsITest.java b/src/it/java/io/weaviate/integration/CollectionsITest.java index 11453dd87..db7ee19ea 100644 --- a/src/it/java/io/weaviate/integration/CollectionsITest.java +++ b/src/it/java/io/weaviate/integration/CollectionsITest.java @@ -372,6 +372,31 @@ public void test_dropPropertyIndex() throws IOException { .returns(false, Property::indexRangeFilters)); } + @Test + public void test_dropVectorIndex() throws IOException { + Weaviate.Version.V137.orSkip(); + + // Arrange + var nsThings = ns("Things"); + var things = client.collections.create(nsThings, + c -> c.vectorConfig(VectorConfig.selfProvided("leaveme"), VectorConfig.selfProvided("dropme"))); + + var config = things.config.get(); + Assertions.assertThat(config).get() + .extracting(CollectionConfig::vectors, InstanceOfAssertFactories.map(String.class, VectorConfig.class)) + .hasSize(2) + .containsKey("dropme"); + + things.config.dropVectorIndex("dropme"); + + config = things.config.get(); + Assertions.assertThat(config).get() + .extracting(CollectionConfig::vectors, InstanceOfAssertFactories.map(String.class, VectorConfig.class)) + .hasSize(2) + .extractingByKey("dropme") + .returns(null, VectorConfig::vectorIndex); // A dropped index has not vectorIndex configuration. + } + @Test public void test_asyncReplicationConfig() throws IOException { Weaviate.Version.latest().orSkip(); diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/VectorConfig.java b/src/main/java/io/weaviate/client6/v1/api/collections/VectorConfig.java index b615ac7c1..dfdc04538 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/VectorConfig.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/VectorConfig.java @@ -1695,7 +1695,12 @@ public void write(JsonWriter out, VectorConfig value) throws IOException { @Override public VectorConfig read(JsonReader in) throws IOException { var jsonObject = JsonParser.parseReader(in).getAsJsonObject(); - var vectorIndexConfig = jsonObject.get("vectorIndexConfig").getAsJsonObject(); + JsonObject vectorIndexConfig = new JsonObject(); + if (jsonObject.has("vectorIndexConfig")) { + // If the vector index has been dropped it will still be present in the + // response, but won't contain "vectorIndexConfig" and "vectorIndexType" fields. + vectorIndexConfig = jsonObject.get("vectorIndexConfig").getAsJsonObject(); + } String quantizationKind = null; for (var kind : new String[] { diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/VectorIndex.java b/src/main/java/io/weaviate/client6/v1/api/collections/VectorIndex.java index 6535c1d6c..af9d7bd6a 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/VectorIndex.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/VectorIndex.java @@ -137,8 +137,22 @@ public void write(JsonWriter out, VectorIndex value) throws IOException { public VectorIndex read(JsonReader in) throws IOException { var jsonObject = JsonParser.parseReader(in).getAsJsonObject(); + var vectorIndexType = jsonObject.get("vectorIndexType"); + if (vectorIndexType == null || vectorIndexType.isJsonNull()) { + // VectorConfig.CustomTypeAdapterFactory cannot provide this + // value for vector indexes that have been dropped. + return null; + } + + var vectorIndexConfig = jsonObject.get("vectorIndexConfig"); + if (vectorIndexConfig == null || vectorIndexConfig.isJsonNull()) { + // VectorConfig.CustomTypeAdapterFactory cannot provide this + // value for vector indexes that have been dropped. + return null; + } + VectorIndex.Kind kind; - var kindString = jsonObject.get("vectorIndexType").getAsString(); + var kindString = vectorIndexType.getAsString(); try { kind = VectorIndex.Kind.valueOfJson(kindString); } catch (IllegalArgumentException e) { @@ -150,7 +164,7 @@ public VectorIndex read(JsonReader in) throws IOException { return null; } - var config = jsonObject.get("vectorIndexConfig").getAsJsonObject(); + var config = vectorIndexConfig.getAsJsonObject(); return adapter.fromJsonTree(config); } }.nullSafe(); diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/config/DeleteVectorIndexRequest.java b/src/main/java/io/weaviate/client6/v1/api/collections/config/DeleteVectorIndexRequest.java new file mode 100644 index 000000000..7b737c198 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/config/DeleteVectorIndexRequest.java @@ -0,0 +1,13 @@ +package io.weaviate.client6.v1.api.collections.config; + +import java.util.Collections; + +import io.weaviate.client6.v1.internal.rest.Endpoint; +import io.weaviate.client6.v1.internal.rest.SimpleEndpoint; + +public record DeleteVectorIndexRequest(String collectionName, String vectorName) { + public static final Endpoint _ENDPOINT = SimpleEndpoint.sideEffect( + request -> "DELETE", + request -> "/schema/" + request.collectionName + "/vectors/" + request.vectorName + "/index", + request -> Collections.emptyMap()); +} diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/config/WeaviateConfigClient.java b/src/main/java/io/weaviate/client6/v1/api/collections/config/WeaviateConfigClient.java index f4a4ee980..87bfc2c92 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/config/WeaviateConfigClient.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/config/WeaviateConfigClient.java @@ -58,6 +58,12 @@ public void dropPropertyIndex(String propertyName, PropertyIndexType indexType) DeletePropertyIndexRequest._ENDPOINT); } + public void dropVectorIndex(String vectorName) throws IOException { + this.restTransport.performRequest( + new DeleteVectorIndexRequest(collection.collectionName(), vectorName), + DeleteVectorIndexRequest._ENDPOINT); + } + public void addReference(String propertyName, String... dataTypes) throws IOException { this.addProperty(ReferenceProperty.to(propertyName, dataTypes).toProperty()); } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/config/WeaviateConfigClientAsync.java b/src/main/java/io/weaviate/client6/v1/api/collections/config/WeaviateConfigClientAsync.java index 7c0cfd0c3..d0d8de936 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/config/WeaviateConfigClientAsync.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/config/WeaviateConfigClientAsync.java @@ -59,6 +59,12 @@ public CompletableFuture dropPropertyIndex(String propertyName, PropertyIn DeletePropertyIndexRequest._ENDPOINT); } + public CompletableFuture dropVectorIndex(String vectorName) throws IOException { + return this.restTransport.performRequestAsync( + new DeleteVectorIndexRequest(collection.collectionName(), vectorName), + DeleteVectorIndexRequest._ENDPOINT); + } + public CompletableFuture addReference(String name, String... dataTypes) throws IOException { return this.addProperty(ReferenceProperty.to(name, dataTypes).toProperty()); }