Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
9 changes: 8 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@ 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-fe5190d.amd64",
]
steps:
- uses: actions/checkout@v4

Expand Down
17 changes: 15 additions & 2 deletions src/it/java/io/weaviate/containers/Weaviate.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -41,17 +41,30 @@ 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;

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];
}
}

/**
Expand Down
42 changes: 42 additions & 0 deletions src/it/java/io/weaviate/integration/CollectionsITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -328,4 +329,45 @@ 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);

config = things.config.get();
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));
}
}
Original file line number Diff line number Diff line change
@@ -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<DeletePropertyIndexRequest, Void> _ENDPOINT = SimpleEndpoint.sideEffect(
request -> "DELETE",
request -> "/schema/" + request.collectionName + "/properties/" + request.propertyName + "/index/"
+ request.indexType.toString(),
request -> Collections.emptyMap());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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;
}

@Override
public String toString() {
return value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ public CompletableFuture<Void> addProperty(Property property) throws IOException
AddPropertyRequest._ENDPOINT);
}

public CompletableFuture<Void> dropPropertyIndex(String propertyName, PropertyIndexType indexType) {
return this.restTransport.performRequestAsync(
new DeletePropertyIndexRequest(collection.collectionName(), propertyName, indexType),
DeletePropertyIndexRequest._ENDPOINT);
}

public CompletableFuture<Void> addReference(String name, String... dataTypes) throws IOException {
return this.addProperty(ReferenceProperty.to(name, dataTypes).toProperty());
}
Expand Down
Loading