From 2038de29f7914ab328140a01d8507f4746818597 Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Tue, 14 Apr 2026 11:15:31 +0200 Subject: [PATCH 1/2] fix(config): read 'none' vector as its own index type --- .github/workflows/test.yaml | 2 +- src/it/java/io/weaviate/containers/Weaviate.java | 2 +- .../io/weaviate/integration/CollectionsITest.java | 4 +++- .../client6/v1/api/collections/VectorIndex.java | 13 +++++++++++-- .../v1/api/collections/vectorindex/None.java | 15 +++++++++++++++ 5 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 src/main/java/io/weaviate/client6/v1/api/collections/vectorindex/None.java diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4bd1c5569..3ed1d1b5e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -92,7 +92,7 @@ jobs: fail-fast: false matrix: WEAVIATE_VERSION: - ["1.32.24", "1.33.11", "1.34.7", "1.35.2", "1.36.9", "1.37.0-rc.0"] + ["1.32.24", "1.33.11", "1.34.7", "1.35.2", "1.36.9", "1.37.0-rc.1"] 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 f0730fb4d..a4cc97734 100644 --- a/src/it/java/io/weaviate/containers/Weaviate.java +++ b/src/it/java/io/weaviate/containers/Weaviate.java @@ -45,7 +45,7 @@ public enum Version { V134(1, 34, 7), V135(1, 35, 2), V136(1, 36, 9), - V137(1, 37, "0-rc.0"); + V137(1, 37, "0-rc.1"); 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 db7ee19ea..889041277 100644 --- a/src/it/java/io/weaviate/integration/CollectionsITest.java +++ b/src/it/java/io/weaviate/integration/CollectionsITest.java @@ -20,6 +20,7 @@ import io.weaviate.client6.v1.api.collections.Replication; import io.weaviate.client6.v1.api.collections.Replication.AsyncReplicationConfig; import io.weaviate.client6.v1.api.collections.VectorConfig; +import io.weaviate.client6.v1.api.collections.VectorIndex; import io.weaviate.client6.v1.api.collections.config.PropertyIndexType; import io.weaviate.client6.v1.api.collections.config.Shard; import io.weaviate.client6.v1.api.collections.config.ShardStatus; @@ -394,7 +395,8 @@ public void test_dropVectorIndex() throws IOException { .extracting(CollectionConfig::vectors, InstanceOfAssertFactories.map(String.class, VectorConfig.class)) .hasSize(2) .extractingByKey("dropme") - .returns(null, VectorConfig::vectorIndex); // A dropped index has not vectorIndex configuration. + .extracting(VectorConfig::vectorIndex) + .matches(VectorIndex::isNone).as("is 'none'"); } @Test 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 af9d7bd6a..35a4f8aff 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 @@ -5,6 +5,7 @@ import java.util.Map; import com.google.gson.Gson; +import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.TypeAdapter; import com.google.gson.TypeAdapterFactory; @@ -17,6 +18,7 @@ import io.weaviate.client6.v1.api.collections.vectorindex.Flat; import io.weaviate.client6.v1.api.collections.vectorindex.HFresh; import io.weaviate.client6.v1.api.collections.vectorindex.Hnsw; +import io.weaviate.client6.v1.api.collections.vectorindex.None; import io.weaviate.client6.v1.internal.TaggedUnion; import io.weaviate.client6.v1.internal.json.JsonEnum; @@ -28,7 +30,8 @@ enum Kind implements JsonEnum { HNSW("hnsw"), FLAT("flat"), DYNAMIC("dynamic"), - HFRESH("hfresh"); + HFRESH("hfresh"), + NONE("none"); private static final Map jsonValueMap = JsonEnum.collectNames(Kind.values()); private final String jsonValue; @@ -87,6 +90,11 @@ default HFresh asHFresh() { return _as(VectorIndex.Kind.HFRESH); } + /** Is this a "none" vector index? */ + default boolean isNone() { + return _is(VectorIndex.Kind.NONE); + } + static enum CustomTypeAdapterFactory implements TypeAdapterFactory { INSTANCE; @@ -102,6 +110,7 @@ private final void init(Gson gson) { addAdapter(gson, VectorIndex.Kind.FLAT, Flat.class); addAdapter(gson, VectorIndex.Kind.DYNAMIC, Dynamic.class); addAdapter(gson, VectorIndex.Kind.HFRESH, HFresh.class); + addAdapter(gson, VectorIndex.Kind.NONE, None.class); } @SuppressWarnings("unchecked") @@ -148,7 +157,7 @@ public VectorIndex read(JsonReader in) throws IOException { if (vectorIndexConfig == null || vectorIndexConfig.isJsonNull()) { // VectorConfig.CustomTypeAdapterFactory cannot provide this // value for vector indexes that have been dropped. - return null; + vectorIndexConfig = new JsonObject(); } VectorIndex.Kind kind; diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorindex/None.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorindex/None.java new file mode 100644 index 000000000..841639ce3 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/vectorindex/None.java @@ -0,0 +1,15 @@ +package io.weaviate.client6.v1.api.collections.vectorindex; + +import io.weaviate.client6.v1.api.collections.VectorIndex; + +public record None() implements VectorIndex { + @Override + public VectorIndex.Kind _kind() { + return VectorIndex.Kind.NONE; + } + + @Override + public Object _self() { + return this; + } +} From efae2aa0f402241b8e674dd7175ff2e11f389860 Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Tue, 21 Apr 2026 13:29:36 +0200 Subject: [PATCH 2/2] refactor(vectorindex): make NoneVectorIndex a private member It should not be possible for a user to create an index with None configuration. It is meant to be read-only. --- .../v1/api/collections/VectorIndex.java | 21 +++++++++++++++++-- .../v1/api/collections/vectorindex/None.java | 15 ------------- 2 files changed, 19 insertions(+), 17 deletions(-) delete mode 100644 src/main/java/io/weaviate/client6/v1/api/collections/vectorindex/None.java 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 35a4f8aff..7fb697830 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 @@ -18,7 +18,6 @@ import io.weaviate.client6.v1.api.collections.vectorindex.Flat; import io.weaviate.client6.v1.api.collections.vectorindex.HFresh; import io.weaviate.client6.v1.api.collections.vectorindex.Hnsw; -import io.weaviate.client6.v1.api.collections.vectorindex.None; import io.weaviate.client6.v1.internal.TaggedUnion; import io.weaviate.client6.v1.internal.json.JsonEnum; @@ -110,7 +109,7 @@ private final void init(Gson gson) { addAdapter(gson, VectorIndex.Kind.FLAT, Flat.class); addAdapter(gson, VectorIndex.Kind.DYNAMIC, Dynamic.class); addAdapter(gson, VectorIndex.Kind.HFRESH, HFresh.class); - addAdapter(gson, VectorIndex.Kind.NONE, None.class); + addAdapter(gson, VectorIndex.Kind.NONE, NoneVectorIndex.class); } @SuppressWarnings("unchecked") @@ -178,5 +177,23 @@ public VectorIndex read(JsonReader in) throws IOException { } }.nullSafe(); } + + /** + * NoneVectorIndex is a special kind of vector index config + * used for an index that has been deleted. It is not possible + * to create an vector index with "none" config, so it stays + * private to it's parent {@link CustomTypeAdapterFactory}. + */ + private record NoneVectorIndex() implements VectorIndex { + @Override + public VectorIndex.Kind _kind() { + return VectorIndex.Kind.NONE; + } + + @Override + public Object _self() { + return this; + } + } } } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/vectorindex/None.java b/src/main/java/io/weaviate/client6/v1/api/collections/vectorindex/None.java deleted file mode 100644 index 841639ce3..000000000 --- a/src/main/java/io/weaviate/client6/v1/api/collections/vectorindex/None.java +++ /dev/null @@ -1,15 +0,0 @@ -package io.weaviate.client6.v1.api.collections.vectorindex; - -import io.weaviate.client6.v1.api.collections.VectorIndex; - -public record None() implements VectorIndex { - @Override - public VectorIndex.Kind _kind() { - return VectorIndex.Kind.NONE; - } - - @Override - public Object _self() { - return this; - } -}