Skip to content

Commit 455decc

Browse files
authored
Merge branch 'main' into feat/ssb
2 parents 413bbb9 + a0e7487 commit 455decc

6 files changed

Lines changed: 88 additions & 1 deletion

File tree

src/it/java/io/weaviate/containers/Weaviate.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ public Weaviate build() {
300300
c.withEnv("ENABLE_MODULES", String.join(",", enableModules));
301301
}
302302

303-
c.withEnv("OBJECTS_TTL_DELETE_SCHEDULE", "0 */6 * * *");
303+
// Required in v1.36.1, but we'll just set it by default.
304+
c.withEnv("OBJECTS_TTL_DELETE_SCHEDULE", "@hourly");
304305

305306
var apiKeyUsers = new HashSet<String>();
306307
apiKeyUsers.addAll(adminUsers);

src/it/java/io/weaviate/integration/CollectionsITest.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import io.weaviate.client6.v1.api.collections.Replication;
2121
import io.weaviate.client6.v1.api.collections.Replication.AsyncReplicationConfig;
2222
import io.weaviate.client6.v1.api.collections.VectorConfig;
23+
import io.weaviate.client6.v1.api.collections.config.PropertyIndexType;
2324
import io.weaviate.client6.v1.api.collections.config.Shard;
2425
import io.weaviate.client6.v1.api.collections.config.ShardStatus;
2526
import io.weaviate.client6.v1.api.collections.generative.DummyGenerative;
@@ -330,6 +331,47 @@ public void test_objectTtl() throws IOException {
330331
.returns(false, ObjectTtl::enabled);
331332
}
332333

334+
@Test
335+
public void test_dropPropertyIndex() throws IOException {
336+
Weaviate.Version.V136.orSkip();
337+
338+
// Arrange
339+
var nsThings = ns("Things");
340+
var things = client.collections.create(nsThings,
341+
c -> c.properties(
342+
Property.text("title", p -> p
343+
.indexFilterable(true)
344+
.indexSearchable(true)),
345+
Property.integer("size", p -> p
346+
.indexRangeFilters(true))));
347+
348+
var config = things.config.get();
349+
Assertions.assertThat(config).get()
350+
.extracting(CollectionConfig::properties, InstanceOfAssertFactories.list(Property.class))
351+
.allSatisfy(property -> {
352+
boolean isNumeric = property.dataTypes().contains(DataType.INT);
353+
354+
Assertions.assertThat(property)
355+
.returns(true, Property::indexFilterable)
356+
.returns(!isNumeric, Property::indexSearchable)
357+
.returns(isNumeric, Property::indexRangeFilters);
358+
});
359+
360+
things.config.dropPropertyIndex("title", PropertyIndexType.FILTERABLE);
361+
things.config.dropPropertyIndex("title", PropertyIndexType.SEARCHABLE);
362+
363+
things.config.dropPropertyIndex("size", PropertyIndexType.FILTERABLE);
364+
things.config.dropPropertyIndex("size", PropertyIndexType.RANGE_FILTERS);
365+
366+
config = things.config.get();
367+
Assertions.assertThat(config).get()
368+
.extracting(CollectionConfig::properties, InstanceOfAssertFactories.list(Property.class))
369+
.allSatisfy(property -> Assertions.assertThat(property)
370+
.returns(false, Property::indexFilterable)
371+
.returns(false, Property::indexSearchable)
372+
.returns(false, Property::indexRangeFilters));
373+
}
374+
333375
@Test
334376
public void test_asyncReplicationConfig() throws IOException {
335377
Weaviate.Version.latest().orSkip();
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package io.weaviate.client6.v1.api.collections.config;
2+
3+
import java.util.Collections;
4+
5+
import io.weaviate.client6.v1.internal.rest.Endpoint;
6+
import io.weaviate.client6.v1.internal.rest.SimpleEndpoint;
7+
8+
public record DeletePropertyIndexRequest(String collectionName, String propertyName, PropertyIndexType indexType) {
9+
public static final Endpoint<DeletePropertyIndexRequest, Void> _ENDPOINT = SimpleEndpoint.sideEffect(
10+
request -> "DELETE",
11+
request -> "/schema/" + request.collectionName + "/properties/" + request.propertyName + "/index/"
12+
+ request.indexType.toString(),
13+
request -> Collections.emptyMap());
14+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package io.weaviate.client6.v1.api.collections.config;
2+
3+
public enum PropertyIndexType {
4+
FILTERABLE("filterable"),
5+
SEARCHABLE("searchable"),
6+
RANGE_FILTERS("rangeFilters");
7+
8+
private final String value;
9+
10+
private PropertyIndexType(String value) {
11+
this.value = value;
12+
}
13+
14+
@Override
15+
public String toString() {
16+
return value;
17+
}
18+
}

src/main/java/io/weaviate/client6/v1/api/collections/config/WeaviateConfigClient.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ public void addProperty(Property property) throws IOException {
5252
AddPropertyRequest._ENDPOINT);
5353
}
5454

55+
public void dropPropertyIndex(String propertyName, PropertyIndexType indexType) throws IOException {
56+
this.restTransport.performRequest(
57+
new DeletePropertyIndexRequest(collection.collectionName(), propertyName, indexType),
58+
DeletePropertyIndexRequest._ENDPOINT);
59+
}
60+
5561
public void addReference(String propertyName, String... dataTypes) throws IOException {
5662
this.addProperty(ReferenceProperty.to(propertyName, dataTypes).toProperty());
5763
}

src/main/java/io/weaviate/client6/v1/api/collections/config/WeaviateConfigClientAsync.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ public CompletableFuture<Void> addProperty(Property property) throws IOException
5353
AddPropertyRequest._ENDPOINT);
5454
}
5555

56+
public CompletableFuture<Void> dropPropertyIndex(String propertyName, PropertyIndexType indexType) {
57+
return this.restTransport.performRequestAsync(
58+
new DeletePropertyIndexRequest(collection.collectionName(), propertyName, indexType),
59+
DeletePropertyIndexRequest._ENDPOINT);
60+
}
61+
5662
public CompletableFuture<Void> addReference(String name, String... dataTypes) throws IOException {
5763
return this.addProperty(ReferenceProperty.to(name, dataTypes).toProperty());
5864
}

0 commit comments

Comments
 (0)