Skip to content

Commit 2ed24a4

Browse files
authored
Merge pull request #397 from weaviate/v6-config-functions
v6: Complete collection configuration and missing `config` functionality (update)
2 parents a2905ee + 1a57727 commit 2ed24a4

27 files changed

Lines changed: 1415 additions & 241 deletions

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
public class Weaviate extends WeaviateContainer {
1515
private WeaviateClient clientInstance;
1616

17-
public static final String VERSION = "1.29.0";
17+
public static final String VERSION = "1.29.1";
1818
public static final String DOCKER_IMAGE = "semitechnologies/weaviate";
1919

2020
/**

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

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88

99
import io.weaviate.ConcurrentTest;
1010
import io.weaviate.client6.v1.api.WeaviateClient;
11+
import io.weaviate.client6.v1.api.collections.CollectionConfig;
12+
import io.weaviate.client6.v1.api.collections.InvertedIndex;
1113
import io.weaviate.client6.v1.api.collections.Property;
14+
import io.weaviate.client6.v1.api.collections.Replication;
1215
import io.weaviate.client6.v1.api.collections.VectorIndex;
13-
import io.weaviate.client6.v1.api.collections.WeaviateCollection;
1416
import io.weaviate.client6.v1.api.collections.vectorindex.Hnsw;
1517
import io.weaviate.client6.v1.api.collections.vectorizers.NoneVectorizer;
1618
import io.weaviate.containers.Container;
@@ -29,8 +31,8 @@ public void testCreateGetDelete() throws IOException {
2931
var thingsCollection = client.collections.getConfig(collectionName);
3032

3133
Assertions.assertThat(thingsCollection).get()
32-
.hasFieldOrPropertyWithValue("name", collectionName)
33-
.extracting(WeaviateCollection::vectors, InstanceOfAssertFactories.map(String.class, VectorIndex.class))
34+
.hasFieldOrPropertyWithValue("collectionName", collectionName)
35+
.extracting(CollectionConfig::vectors, InstanceOfAssertFactories.map(String.class, VectorIndex.class))
3436
.as("default vector").extractingByKey("default")
3537
.satisfies(defaultVector -> {
3638
Assertions.assertThat(defaultVector).extracting(VectorIndex::vectorizer)
@@ -61,7 +63,7 @@ public void testCrossReferences() throws IOException {
6163
.as("after create Things").get()
6264
.satisfies(c -> {
6365
Assertions.assertThat(c.references())
64-
.as("ownedBy").filteredOn(p -> p.name().equals("ownedBy")).first()
66+
.as("ownedBy").filteredOn(p -> p.propertyName().equals("ownedBy")).first()
6567
.extracting(p -> p.dataTypes(), InstanceOfAssertFactories.LIST)
6668
.containsOnly(nsOwners);
6769
});
@@ -81,7 +83,7 @@ public void testCrossReferences() throws IOException {
8183
.as("after add property").get()
8284
.satisfies(c -> {
8385
Assertions.assertThat(c.references())
84-
.as("soldIn").filteredOn(p -> p.name().equals("soldIn")).first()
86+
.as("soldIn").filteredOn(p -> p.propertyName().equals("soldIn")).first()
8587
.extracting(p -> p.dataTypes(), InstanceOfAssertFactories.LIST)
8688
.containsOnly(nsOnlineStores, nsMarkets);
8789
});
@@ -105,7 +107,7 @@ public void testListDeleteAll() throws IOException {
105107
var all = client.collections.list();
106108
Assertions.assertThat(all)
107109
.hasSizeGreaterThanOrEqualTo(3)
108-
.extracting(WeaviateCollection::name)
110+
.extracting(CollectionConfig::collectionName)
109111
.contains(nsA, nsB, nsC);
110112

111113
client.collections.deleteAll();
@@ -114,4 +116,47 @@ public void testListDeleteAll() throws IOException {
114116
Assertions.assertThat(all.isEmpty());
115117

116118
}
119+
120+
@Test
121+
public void testUpdateCollection() throws IOException {
122+
var nsBoxes = ns("Boxes");
123+
var nsThings = ns("Things");
124+
125+
client.collections.create(nsBoxes);
126+
127+
client.collections.create(nsThings,
128+
collection -> collection
129+
.description("Things stored in boxes")
130+
.properties(
131+
Property.text("name"),
132+
Property.integer("width",
133+
w -> w.description("how wide this thing is")))
134+
.invertedIndex(idx -> idx.cleanupIntervalSeconds(10))
135+
.replication(repl -> repl.asyncEnabled(true)));
136+
137+
var things = client.collections.use(nsThings);
138+
139+
// Act
140+
things.config.update(nsThings, collection -> collection
141+
.description("Things stored on shelves")
142+
.propertyDescription("width", "not height")
143+
.invertedIndex(idx -> idx.cleanupIntervalSeconds(30))
144+
.replication(repl -> repl.asyncEnabled(false)));
145+
146+
// Assert
147+
var updated = things.config.get();
148+
Assertions.assertThat(updated).get()
149+
.returns("Things stored on shelves", CollectionConfig::description)
150+
.satisfies(collection -> {
151+
Assertions.assertThat(collection)
152+
.extracting(CollectionConfig::properties, InstanceOfAssertFactories.list(Property.class))
153+
.extracting(Property::description).contains("not height");
154+
155+
Assertions.assertThat(collection)
156+
.extracting(CollectionConfig::invertedIndex).returns(30, InvertedIndex::cleanupIntervalSeconds);
157+
158+
Assertions.assertThat(collection)
159+
.extracting(CollectionConfig::replication).returns(false, Replication::asyncEnabled);
160+
});
161+
}
117162
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void testReferences() throws IOException {
6161
.as("Artists: create collection")
6262
.extracting(c -> c.references().stream().findFirst())
6363
.as("has one reference property").extracting(Optional::get)
64-
.returns("hasAwards", ReferenceProperty::name)
64+
.returns("hasAwards", ReferenceProperty::propertyName)
6565
.extracting(ReferenceProperty::dataTypes, InstanceOfAssertFactories.list(String.class))
6666
.containsOnly(nsGrammy, nsOscar);
6767

@@ -87,7 +87,7 @@ public void testReferences() throws IOException {
8787
Assertions.assertThat(collectionArtists).get()
8888
.as("Artists: add reference to Movies")
8989
.extracting(c -> c.references().stream()
90-
.filter(property -> property.name().equals("featuredIn")).findFirst())
90+
.filter(property -> property.propertyName().equals("featuredIn")).findFirst())
9191
.as("featuredIn reference property").extracting(Optional::get)
9292
.extracting(ReferenceProperty::dataTypes, InstanceOfAssertFactories.list(String.class))
9393
.containsOnly(nsMovies);

0 commit comments

Comments
 (0)