diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index cdcf934fc..50fe6d1b1 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -78,7 +78,8 @@ jobs: strategy: fail-fast: false matrix: - WEAVIATE_VERSION: ["1.32.24", "1.33.11", "1.34.7", "1.35.2"] + WEAVIATE_VERSION: + ["1.32.24", "1.33.11", "1.34.7", "1.35.2", "1.36.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 0f463e96f..c12bf9f6e 100644 --- a/src/it/java/io/weaviate/containers/Weaviate.java +++ b/src/it/java/io/weaviate/containers/Weaviate.java @@ -26,7 +26,7 @@ public class Weaviate extends WeaviateContainer { public static final String DOCKER_IMAGE = "semitechnologies/weaviate"; - public static final String LATEST_VERSION = Version.V135.semver.toString(); + public static final String LATEST_VERSION = Version.latest().semver.toString(); public static final String VERSION; static { @@ -41,7 +41,8 @@ public enum Version { V132(1, 32, 24), V133(1, 33, 11), V134(1, 34, 7), - V135(1, 35, 2); + V135(1, 35, 2), + V136(1, 36, "0-rc.0"); public final SemanticVersion semver; @@ -49,9 +50,21 @@ private Version(int major, int minor, int patch) { this.semver = new SemanticVersion(major, minor, patch); } + private Version(int major, int minor, String patch) { + this.semver = new SemanticVersion(major, minor, patch); + } + public void orSkip() { ConcurrentTest.requireAtLeast(this); } + + public static Version latest() { + Version[] versions = Version.class.getEnumConstants(); + if (versions == null) { + throw new IllegalStateException("No versions are defined"); + } + return versions[versions.length - 1]; + } } /** diff --git a/src/it/java/io/weaviate/integration/CollectionsITest.java b/src/it/java/io/weaviate/integration/CollectionsITest.java index 8d68bb1c6..ede5d8903 100644 --- a/src/it/java/io/weaviate/integration/CollectionsITest.java +++ b/src/it/java/io/weaviate/integration/CollectionsITest.java @@ -19,6 +19,7 @@ import io.weaviate.client6.v1.api.collections.ReferenceProperty; import io.weaviate.client6.v1.api.collections.Replication; import io.weaviate.client6.v1.api.collections.VectorConfig; +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; import io.weaviate.client6.v1.api.collections.generative.DummyGenerative; @@ -328,4 +329,44 @@ public void test_objectTtl() throws IOException { .extracting(CollectionConfig::objectTtl).isNotNull() .returns(false, ObjectTtl::enabled); } + + @Test + public void test_dropPropertyIndex() throws IOException { + Weaviate.Version.V136.orSkip(); + + // Arrange + var nsThings = ns("Things"); + var things = client.collections.create(nsThings, + c -> c.properties( + Property.text("title", p -> p + .indexFilterable(true) + .indexSearchable(true)), + Property.integer("size", p -> p + .indexRangeFilters(true)))); + + var config = things.config.get(); + Assertions.assertThat(config).get() + .extracting(CollectionConfig::properties, InstanceOfAssertFactories.list(Property.class)) + .allSatisfy(property -> { + boolean isNumeric = property.dataTypes().contains(DataType.INT); + + Assertions.assertThat(property) + .returns(true, Property::indexFilterable) + .returns(!isNumeric, Property::indexSearchable) + .returns(isNumeric, Property::indexRangeFilters); + }); + + things.config.dropPropertyIndex("title", PropertyIndexType.FILTERABLE); + things.config.dropPropertyIndex("title", PropertyIndexType.SEARCHABLE); + + things.config.dropPropertyIndex("size", PropertyIndexType.FILTERABLE); + things.config.dropPropertyIndex("size", PropertyIndexType.RANGE_FILTERS); + + Assertions.assertThat(config).get() + .extracting(CollectionConfig::properties, InstanceOfAssertFactories.list(Property.class)) + .allSatisfy(property -> Assertions.assertThat(property) + .returns(false, Property::indexFilterable) + .returns(false, Property::indexSearchable) + .returns(false, Property::indexRangeFilters)); + } } diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/config/DeletePropertyIndexRequest.java b/src/main/java/io/weaviate/client6/v1/api/collections/config/DeletePropertyIndexRequest.java new file mode 100644 index 000000000..7b8c3bfa6 --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/config/DeletePropertyIndexRequest.java @@ -0,0 +1,14 @@ +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 DeletePropertyIndexRequest(String collectionName, String propertyName, PropertyIndexType indexType) { + public static final Endpoint _ENDPOINT = SimpleEndpoint.sideEffect( + request -> "DELETE", + request -> "/schema/" + request.collectionName + "/properties/" + request.propertyName + "/index/" + + request.indexType.toString(), + request -> Collections.emptyMap()); +} diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/config/PropertyIndexType.java b/src/main/java/io/weaviate/client6/v1/api/collections/config/PropertyIndexType.java new file mode 100644 index 000000000..8695bd94e --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/api/collections/config/PropertyIndexType.java @@ -0,0 +1,17 @@ +package io.weaviate.client6.v1.api.collections.config; + +public enum PropertyIndexType { + FILTERABLE("filterable"), + SEARCHABLE("searchable"), + RANGE_FILTERS("rangeFilters"); + + private final String value; + + private PropertyIndexType(String value) { + this.value = value; + } + + public String toString() { + return value; + } +} 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 33d50fb01..f4a4ee980 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 @@ -52,6 +52,12 @@ public void addProperty(Property property) throws IOException { AddPropertyRequest._ENDPOINT); } + public void dropPropertyIndex(String propertyName, PropertyIndexType indexType) throws IOException { + this.restTransport.performRequest( + new DeletePropertyIndexRequest(collection.collectionName(), propertyName, indexType), + DeletePropertyIndexRequest._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 1c5d8f169..7c0cfd0c3 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 @@ -53,6 +53,12 @@ public CompletableFuture addProperty(Property property) throws IOException AddPropertyRequest._ENDPOINT); } + public CompletableFuture dropPropertyIndex(String propertyName, PropertyIndexType indexType) { + return this.restTransport.performRequestAsync( + new DeletePropertyIndexRequest(collection.collectionName(), propertyName, indexType), + DeletePropertyIndexRequest._ENDPOINT); + } + public CompletableFuture addReference(String name, String... dataTypes) throws IOException { return this.addProperty(ReferenceProperty.to(name, dataTypes).toProperty()); }