Skip to content

v6: fix async toolchain #392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
36 changes: 35 additions & 1 deletion src/it/java/io/weaviate/integration/SearchITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;

import org.assertj.core.api.Assertions;
import org.assertj.core.api.InstanceOfAssertFactories;
Expand Down Expand Up @@ -258,7 +259,7 @@ public void testFetchObjectsWithFilters() throws IOException {
}

@Test
public void testBm25() throws IOException {
public void testBm25() throws IOException, InterruptedException, ExecutionException {
var nsWords = ns("Words");

client.collections.create(nsWords,
Expand All @@ -281,4 +282,37 @@ public void testBm25() throws IOException {
.extracting(WeaviateObject::metadata).extracting(QueryMetadata::uuid)
.containsOnly(want.metadata().uuid());
}

/**
* Minimal test to verify async functionality works as expected.
* We will extend our testing framework at a later stage to automatically
* test both sync/async clients.
*/
@Test
public void testBm25_async() throws IOException, InterruptedException, ExecutionException {
var nsWords = ns("Words");

try (final var async = client.async()) {
async.collections.create(nsWords,
collection -> collection
.properties(
Property.text("relevant"),
Property.text("irrelevant")))
.get();

var words = async.collections.use(nsWords);

/* notWant */ words.data.insert(Map.of("relevant", "elefant", "irrelevant", "dollar bill")).get();
var want = words.data.insert(Map.of("relevant", "a dime a dollar", "irrelevant", "euro")).get();

var dollarWorlds = words.query.bm25(
"dollar",
bm25 -> bm25.queryProperties("relevant")).get();

Assertions.assertThat(dollarWorlds.objects())
.hasSize(1)
.extracting(WeaviateObject::metadata).extracting(QueryMetadata::uuid)
.containsOnly(want.metadata().uuid());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public WeaviateCollectionsClientAsync(RestTransport restTransport, GrpcTransport
this.grpcTransport = grpcTransport;
}

public CollectionHandle<Map<String, Object>> use(String collectionName) {
return new CollectionHandle<>(restTransport, grpcTransport,
public CollectionHandleAsync<Map<String, Object>> use(String collectionName) {
return new CollectionHandleAsync<>(restTransport, grpcTransport,
CollectionDescriptor.ofMap(collectionName));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void cancelled() {

});
// FIXME: we need to differentiate between "no body" and "soumething's wrong"
return completable.thenApply(r -> r.getBody() == null
return completable.thenApply(r -> r.getBody() != null
? endpoint.deserializeResponse(gson, r.getBody().getBodyText())
: null);
}
Expand Down