From 931b27b499f163474991306440ad8289930338ee Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Mon, 3 Nov 2025 18:23:32 +0100 Subject: [PATCH 01/15] feat: set connection / query / insert timeouts --- .../io/weaviate/client6/v1/api/Config.java | 70 ++++++++++++++----- .../client6/v1/api/WeaviateClient.java | 4 +- .../client6/v1/api/WeaviateClientAsync.java | 4 +- .../collections/data/InsertManyRequest.java | 2 +- .../query/AbstractQueryClient.java | 25 +++++++ .../api/collections/query/FetchObjects.java | 4 ++ .../weaviate/client6/v1/internal/Timeout.java | 11 +++ .../client6/v1/internal/TransportOptions.java | 9 ++- .../internal/grpc/DefaultGrpcTransport.java | 21 +++++- .../v1/internal/grpc/GrpcChannelOptions.java | 12 ++-- .../client6/v1/internal/grpc/Rpc.java | 37 ++++------ .../client6/v1/internal/grpc/SimpleRpc.java | 56 +++++++++++++++ .../internal/rest/DefaultRestTransport.java | 12 ++++ .../internal/rest/RestTransportOptions.java | 14 +++- .../client6/v1/api/AuthenticationTest.java | 5 +- .../client6/v1/api/WeaviateClientTest.java | 5 +- .../rest/DefaultRestTransportTest.java | 3 +- 17 files changed, 235 insertions(+), 59 deletions(-) create mode 100644 src/main/java/io/weaviate/client6/v1/internal/Timeout.java create mode 100644 src/main/java/io/weaviate/client6/v1/internal/grpc/SimpleRpc.java diff --git a/src/main/java/io/weaviate/client6/v1/api/Config.java b/src/main/java/io/weaviate/client6/v1/api/Config.java index 3edc1ffe5..5e50b610d 100644 --- a/src/main/java/io/weaviate/client6/v1/api/Config.java +++ b/src/main/java/io/weaviate/client6/v1/api/Config.java @@ -8,6 +8,7 @@ import javax.net.ssl.TrustManagerFactory; import io.weaviate.client6.v1.internal.ObjectBuilder; +import io.weaviate.client6.v1.internal.Timeout; import io.weaviate.client6.v1.internal.TokenProvider; import io.weaviate.client6.v1.internal.grpc.GrpcChannelOptions; import io.weaviate.client6.v1.internal.rest.RestTransportOptions; @@ -20,7 +21,8 @@ public record Config( int grpcPort, Map headers, Authentication authentication, - TrustManagerFactory trustManagerFactory) { + TrustManagerFactory trustManagerFactory, + Timeout timeout) { public static Config of(Function> fn) { return fn.apply(new Custom()).build(); @@ -35,7 +37,8 @@ private Config(Builder builder) { builder.grpcPort, builder.headers, builder.authentication, - builder.trustManagerFactory); + builder.trustManagerFactory, + builder.timeout); } RestTransportOptions restTransportOptions() { @@ -43,7 +46,7 @@ RestTransportOptions restTransportOptions() { } RestTransportOptions restTransportOptions(TokenProvider tokenProvider) { - return new RestTransportOptions(scheme, httpHost, httpPort, headers, tokenProvider, trustManagerFactory); + return new RestTransportOptions(scheme, httpHost, httpPort, headers, tokenProvider, trustManagerFactory, timeout); } GrpcChannelOptions grpcTransportOptions() { @@ -51,10 +54,10 @@ GrpcChannelOptions grpcTransportOptions() { } GrpcChannelOptions grpcTransportOptions(TokenProvider tokenProvider) { - return new GrpcChannelOptions(scheme, grpcHost, grpcPort, headers, tokenProvider, trustManagerFactory); + return new GrpcChannelOptions(scheme, grpcHost, grpcPort, headers, tokenProvider, trustManagerFactory, timeout); } - private abstract static class Builder> implements ObjectBuilder { + private abstract static class Builder> implements ObjectBuilder { protected String scheme; protected String httpHost; @@ -63,6 +66,7 @@ private abstract static class Builder> implements Obj protected int grpcPort; protected Authentication authentication; protected TrustManagerFactory trustManagerFactory; + protected Timeout timeout = new Timeout(); protected Map headers = new HashMap<>(); /** @@ -70,9 +74,9 @@ private abstract static class Builder> implements Obj * {@code public} if using a different scheme is allowed. */ @SuppressWarnings("unchecked") - protected SELF scheme(String scheme) { + protected SelfT scheme(String scheme) { this.scheme = scheme; - return (SELF) this; + return (SelfT) this; } /** @@ -80,9 +84,9 @@ protected SELF scheme(String scheme) { * method to {@code public} if using a different port is allowed. */ @SuppressWarnings("unchecked") - protected SELF httpHost(String httpHost) { + protected SelfT httpHost(String httpHost) { this.httpHost = trimScheme(httpHost); - return (SELF) this; + return (SelfT) this; } /** @@ -90,9 +94,9 @@ protected SELF httpHost(String httpHost) { * method to {@code public} if using a different port is allowed. */ @SuppressWarnings("unchecked") - protected SELF grpcHost(String grpcHost) { + protected SelfT grpcHost(String grpcHost) { this.grpcHost = trimScheme(grpcHost); - return (SELF) this; + return (SelfT) this; } /** Remove leading http(s):// prefix from a URL, if present. */ @@ -105,9 +109,9 @@ private String trimScheme(String url) { * secure connection should expose this method. */ @SuppressWarnings("unchecked") - protected SELF trustManagerFactory(TrustManagerFactory tmf) { + protected SelfT trustManagerFactory(TrustManagerFactory tmf) { this.trustManagerFactory = tmf; - return (SELF) this; + return (SelfT) this; } /** @@ -115,9 +119,9 @@ protected SELF trustManagerFactory(TrustManagerFactory tmf) { * will not use any authentication mechanism. */ @SuppressWarnings("unchecked") - public SELF authentication(Authentication authz) { + public SelfT authentication(Authentication authz) { this.authentication = authz; - return (SELF) this; + return (SelfT) this; } /** @@ -126,9 +130,9 @@ public SELF authentication(Authentication authz) { * This will be applied both to REST and gRPC requests. */ @SuppressWarnings("unchecked") - public SELF setHeader(String key, String value) { + public SelfT setHeader(String key, String value) { this.headers.put(key, value); - return (SELF) this; + return (SelfT) this; } /** @@ -136,9 +140,37 @@ public SELF setHeader(String key, String value) { * This will be applied both to REST and gRPC requests. */ @SuppressWarnings("unchecked") - public SELF setHeaders(Map headers) { + public SelfT setHeaders(Map headers) { this.headers.putAll(Map.copyOf(headers)); - return (SELF) this; + return (SelfT) this; + } + + /** + * Set connection, query, and insert timeout to the same value. + * + * @param timeoutSeconds Response timeout in seconds. + */ + @SuppressWarnings("unchecked") + public SelfT timeout(int timeoutSeconds) { + this.timeout = new Timeout(timeoutSeconds); + return (SelfT) this; + } + + /** + * Set individual connection, query, and insert timeouts. + * + *

+ * Because all inserts go over gRPC connection, the REST requests + * will assume {@code querySeconds} timeouts. + * + * @param initSeconds Connection timeout in seconds. + * @param querySeconds Response timeout for query requests. + * @param insertSeconds Response timeout for insert requests. + */ + @SuppressWarnings("unchecked") + public SelfT timeout(int initSeconds, int querySeconds, int insertSeconds) { + this.timeout = new Timeout(initSeconds, querySeconds, insertSeconds); + return (SelfT) this; } /** diff --git a/src/main/java/io/weaviate/client6/v1/api/WeaviateClient.java b/src/main/java/io/weaviate/client6/v1/api/WeaviateClient.java index d93f7eb89..a4c51cbe9 100644 --- a/src/main/java/io/weaviate/client6/v1/api/WeaviateClient.java +++ b/src/main/java/io/weaviate/client6/v1/api/WeaviateClient.java @@ -11,6 +11,7 @@ import io.weaviate.client6.v1.api.rbac.roles.WeaviateRolesClient; import io.weaviate.client6.v1.api.rbac.users.WeaviateUsersClient; import io.weaviate.client6.v1.internal.ObjectBuilder; +import io.weaviate.client6.v1.internal.Timeout; import io.weaviate.client6.v1.internal.TokenProvider; import io.weaviate.client6.v1.internal.grpc.DefaultGrpcTransport; import io.weaviate.client6.v1.internal.grpc.GrpcChannelOptions; @@ -83,7 +84,8 @@ public WeaviateClient(Config config) { // the associated resources in case we have to throw an exception. // Assign to this.restTransport only once we're in the clear to // avoid publishing the object before it's fully initialized. - var _restTransport = new DefaultRestTransport(restOpt); + var _restTransport = new DefaultRestTransport(restOpt.withTimeout( + new Timeout(restOpt.timeout().initSeconds()))); boolean isLive = false; InstanceMetadata meta = null; try { diff --git a/src/main/java/io/weaviate/client6/v1/api/WeaviateClientAsync.java b/src/main/java/io/weaviate/client6/v1/api/WeaviateClientAsync.java index 85f6103db..7858300ec 100644 --- a/src/main/java/io/weaviate/client6/v1/api/WeaviateClientAsync.java +++ b/src/main/java/io/weaviate/client6/v1/api/WeaviateClientAsync.java @@ -13,6 +13,7 @@ import io.weaviate.client6.v1.api.rbac.roles.WeaviateRolesClientAsync; import io.weaviate.client6.v1.api.rbac.users.WeaviateUsersClientAsync; import io.weaviate.client6.v1.internal.ObjectBuilder; +import io.weaviate.client6.v1.internal.Timeout; import io.weaviate.client6.v1.internal.TokenProvider; import io.weaviate.client6.v1.internal.grpc.DefaultGrpcTransport; import io.weaviate.client6.v1.internal.grpc.GrpcChannelOptions; @@ -86,7 +87,8 @@ public WeaviateClientAsync(Config config) { // the associated resources in case we have to throw an exception. // Assign to this.restTransport only once we're in the clear to // avoid publishing the object before it's fully initialized. - var _restTransport = new DefaultRestTransport(restOpt); + var _restTransport = new DefaultRestTransport(restOpt.withTimeout( + new Timeout(restOpt.timeout().initSeconds()))); boolean isLive = false; InstanceMetadata meta = null; try { diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/data/InsertManyRequest.java b/src/main/java/io/weaviate/client6/v1/api/collections/data/InsertManyRequest.java index 65da1dced..c41a51057 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/data/InsertManyRequest.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/data/InsertManyRequest.java @@ -42,7 +42,7 @@ public static Rpc, WeaviateProtoBatch.BatchObjectsReque List> insertObjects, CollectionDescriptor collection, CollectionHandleDefaults defaults) { - return Rpc.of( + return Rpc.insert( request -> { var message = WeaviateProtoBatch.BatchObjectsRequest.newBuilder(); diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/query/AbstractQueryClient.java b/src/main/java/io/weaviate/client6/v1/api/collections/query/AbstractQueryClient.java index 887bc53fc..36abd514c 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/query/AbstractQueryClient.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/query/AbstractQueryClient.java @@ -82,6 +82,16 @@ protected final Optional> optionalF // Object queries ----------------------------------------------------------- + /** + * Retrieve objects in ascending UUID order. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + */ + public ResponseT fetchObjects() { + return fetchObjects(FetchObjects.of()); + } + /** * Retrieve objects without applying a Vector Search or Keyword Search filter. * @@ -104,6 +114,21 @@ public ResponseT fetchObjects(FetchObjects query) { return performRequest(query); } + /** + * Retrieve objects in ascending UUID order. + * + * @param groupBy Group-by clause. + * @return Grouped query result. + * @throws WeaviateApiException in case the server returned with an + * error status code. + * + * @see GroupBy + * @see QueryResponseGrouped + */ + public GroupedResponseT fetchObjects(GroupBy groupBy) { + return fetchObjects(FetchObjects.of(), groupBy); + } + /** * Retrieve objects without applying a Vector Search or Keyword Search filter. * diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/query/FetchObjects.java b/src/main/java/io/weaviate/client6/v1/api/collections/query/FetchObjects.java index e132497df..ae2147a94 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/query/FetchObjects.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/query/FetchObjects.java @@ -10,6 +10,10 @@ public record FetchObjects(BaseQueryOptions common, List sortBy) implements QueryOperator { + public static FetchObjects of() { + return of(ObjectBuilder.identity()); + } + public static FetchObjects of(Function> fn) { return fn.apply(new Builder()).build(); } diff --git a/src/main/java/io/weaviate/client6/v1/internal/Timeout.java b/src/main/java/io/weaviate/client6/v1/internal/Timeout.java new file mode 100644 index 000000000..711078a3d --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/internal/Timeout.java @@ -0,0 +1,11 @@ +package io.weaviate.client6.v1.internal; + +public record Timeout(int initSeconds, int querySeconds, int insertSeconds) { + public Timeout() { + this(30, 60, 120); + } + + public Timeout(int timeout) { + this(timeout, timeout, timeout); + } +} diff --git a/src/main/java/io/weaviate/client6/v1/internal/TransportOptions.java b/src/main/java/io/weaviate/client6/v1/internal/TransportOptions.java index 60d3db0d5..897bb28cd 100644 --- a/src/main/java/io/weaviate/client6/v1/internal/TransportOptions.java +++ b/src/main/java/io/weaviate/client6/v1/internal/TransportOptions.java @@ -10,14 +10,16 @@ public abstract class TransportOptions { protected final TokenProvider tokenProvider; protected final H headers; protected final TrustManagerFactory trustManagerFactory; + protected final Timeout timeout; protected TransportOptions(String scheme, String host, int port, H headers, TokenProvider tokenProvider, - TrustManagerFactory tmf) { + TrustManagerFactory tmf, Timeout timeout) { this.scheme = scheme; this.host = host; this.port = port; this.tokenProvider = tokenProvider; this.headers = headers; + this.timeout = timeout; this.trustManagerFactory = tmf; } @@ -37,6 +39,11 @@ public int port() { return this.port; } + @Nullable + public Timeout timeout() { + return this.timeout; + } + @Nullable public TokenProvider tokenProvider() { return this.tokenProvider; diff --git a/src/main/java/io/weaviate/client6/v1/internal/grpc/DefaultGrpcTransport.java b/src/main/java/io/weaviate/client6/v1/internal/grpc/DefaultGrpcTransport.java index bb4a8aa88..9f8fc8036 100644 --- a/src/main/java/io/weaviate/client6/v1/internal/grpc/DefaultGrpcTransport.java +++ b/src/main/java/io/weaviate/client6/v1/internal/grpc/DefaultGrpcTransport.java @@ -1,6 +1,7 @@ package io.weaviate.client6.v1.internal.grpc; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLException; @@ -13,6 +14,7 @@ import io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts; import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder; import io.grpc.netty.shaded.io.netty.handler.ssl.SslContext; +import io.grpc.stub.AbstractStub; import io.grpc.stub.MetadataUtils; import io.weaviate.client6.v1.api.WeaviateApiException; import io.weaviate.client6.v1.internal.grpc.protocol.WeaviateGrpc; @@ -25,9 +27,12 @@ public final class DefaultGrpcTransport implements GrpcTransport { private final WeaviateBlockingStub blockingStub; private final WeaviateFutureStub futureStub; + private final GrpcChannelOptions transportOptions; + private TokenCallCredentials callCredentials; public DefaultGrpcTransport(GrpcChannelOptions transportOptions) { + this.transportOptions = transportOptions; this.channel = buildChannel(transportOptions); var blockingStub = WeaviateGrpc.newBlockingStub(channel) @@ -52,13 +57,24 @@ public DefaultGrpcTransport(GrpcChannelOptions transportOptions) { this.futureStub = futureStub; } + private > StubT applyTimeout(StubT stub, Rpc rpc) { + if (transportOptions.timeout() == null) { + return stub; + } + var timeout = rpc.isInsert() + ? transportOptions.timeout().insertSeconds() + : transportOptions.timeout().querySeconds(); + return stub.withDeadlineAfter(timeout, TimeUnit.SECONDS); + } + @Override public ResponseT performRequest(RequestT request, Rpc rpc) { var message = rpc.marshal(request); var method = rpc.method(); + var stub = applyTimeout(blockingStub, rpc); try { - var reply = method.apply(blockingStub, message); + var reply = method.apply(stub, message); return rpc.unmarshal(reply); } catch (io.grpc.StatusRuntimeException e) { throw WeaviateApiException.gRPC(e); @@ -70,7 +86,8 @@ public CompletableFuture perf Rpc rpc) { var message = rpc.marshal(request); var method = rpc.methodAsync(); - var reply = method.apply(futureStub, message); + var stub = applyTimeout(futureStub, rpc); + var reply = method.apply(stub, message); return toCompletableFuture(reply).thenApply(r -> rpc.unmarshal(r)); } diff --git a/src/main/java/io/weaviate/client6/v1/internal/grpc/GrpcChannelOptions.java b/src/main/java/io/weaviate/client6/v1/internal/grpc/GrpcChannelOptions.java index e59893412..5e4453d7f 100644 --- a/src/main/java/io/weaviate/client6/v1/internal/grpc/GrpcChannelOptions.java +++ b/src/main/java/io/weaviate/client6/v1/internal/grpc/GrpcChannelOptions.java @@ -5,6 +5,7 @@ import javax.net.ssl.TrustManagerFactory; import io.grpc.Metadata; +import io.weaviate.client6.v1.internal.Timeout; import io.weaviate.client6.v1.internal.TokenProvider; import io.weaviate.client6.v1.internal.TransportOptions; @@ -12,18 +13,19 @@ public class GrpcChannelOptions extends TransportOptions { private final Integer maxMessageSize; public GrpcChannelOptions(String scheme, String host, int port, Map headers, - TokenProvider tokenProvider, TrustManagerFactory tmf) { - this(scheme, host, port, buildMetadata(headers), tokenProvider, tmf, null); + TokenProvider tokenProvider, TrustManagerFactory tmf, Timeout timeout) { + this(scheme, host, port, buildMetadata(headers), tokenProvider, tmf, null, timeout); } private GrpcChannelOptions(String scheme, String host, int port, Metadata headers, - TokenProvider tokenProvider, TrustManagerFactory tmf, Integer maxMessageSize) { - super(scheme, host, port, headers, tokenProvider, tmf); + TokenProvider tokenProvider, TrustManagerFactory tmf, Integer maxMessageSize, Timeout timeout) { + super(scheme, host, port, headers, tokenProvider, tmf, timeout); this.maxMessageSize = maxMessageSize; } public GrpcChannelOptions withMaxMessageSize(int maxMessageSize) { - return new GrpcChannelOptions(scheme, host, port, headers, tokenProvider, trustManagerFactory, maxMessageSize); + return new GrpcChannelOptions(scheme, host, port, headers, tokenProvider, trustManagerFactory, maxMessageSize, + timeout); } public Integer maxMessageSize() { diff --git a/src/main/java/io/weaviate/client6/v1/internal/grpc/Rpc.java b/src/main/java/io/weaviate/client6/v1/internal/grpc/Rpc.java index d98485cb3..8bf863b78 100644 --- a/src/main/java/io/weaviate/client6/v1/internal/grpc/Rpc.java +++ b/src/main/java/io/weaviate/client6/v1/internal/grpc/Rpc.java @@ -18,32 +18,23 @@ public interface Rpc { BiFunction> methodAsync(); - public static Rpc of( + default boolean isInsert() { + return false; + } + + public static SimpleRpc of( + Function marshal, + Function unmarshal, + Supplier> method, + Supplier>> methodAsync) { + return new SimpleRpc<>(marshal, unmarshal, method, methodAsync, false); + } + + public static SimpleRpc insert( Function marshal, Function unmarshal, Supplier> method, Supplier>> methodAsync) { - return new Rpc() { - - @Override - public RequestM marshal(RequestT request) { - return marshal.apply(request); - } - - @Override - public ResponseT unmarshal(ReplyM reply) { - return unmarshal.apply(reply); - } - - @Override - public BiFunction method() { - return method.get(); - } - - @Override - public BiFunction> methodAsync() { - return methodAsync.get(); - } - }; + return new SimpleRpc<>(marshal, unmarshal, method, methodAsync, true); } } diff --git a/src/main/java/io/weaviate/client6/v1/internal/grpc/SimpleRpc.java b/src/main/java/io/weaviate/client6/v1/internal/grpc/SimpleRpc.java new file mode 100644 index 000000000..ebde06dee --- /dev/null +++ b/src/main/java/io/weaviate/client6/v1/internal/grpc/SimpleRpc.java @@ -0,0 +1,56 @@ +package io.weaviate.client6.v1.internal.grpc; + +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Supplier; + +import com.google.common.util.concurrent.ListenableFuture; + +import io.weaviate.client6.v1.internal.grpc.protocol.WeaviateGrpc.WeaviateBlockingStub; +import io.weaviate.client6.v1.internal.grpc.protocol.WeaviateGrpc.WeaviateFutureStub; + +public class SimpleRpc implements Rpc { + + private final boolean isInsert; + + private final Function marshal; + private final Function unmarshal; + private final Supplier> method; + private final Supplier>> methodAsync; + + SimpleRpc(Function marshal, Function unmarshal, + Supplier> method, + Supplier>> methodAsync, + boolean isInsert) { + this.marshal = marshal; + this.unmarshal = unmarshal; + this.method = method; + this.methodAsync = methodAsync; + this.isInsert = isInsert; + } + + @Override + public RequestM marshal(RequestT request) { + return marshal.apply(request); + } + + @Override + public ResponseT unmarshal(ReplyM reply) { + return unmarshal.apply(reply); + } + + @Override + public BiFunction method() { + return method.get(); + } + + @Override + public BiFunction> methodAsync() { + return methodAsync.get(); + } + + @Override + public boolean isInsert() { + return isInsert; + } +} diff --git a/src/main/java/io/weaviate/client6/v1/internal/rest/DefaultRestTransport.java b/src/main/java/io/weaviate/client6/v1/internal/rest/DefaultRestTransport.java index 24357b1a7..a77d9da29 100644 --- a/src/main/java/io/weaviate/client6/v1/internal/rest/DefaultRestTransport.java +++ b/src/main/java/io/weaviate/client6/v1/internal/rest/DefaultRestTransport.java @@ -4,11 +4,13 @@ import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLContext; import org.apache.hc.client5.http.async.methods.SimpleHttpRequest; import org.apache.hc.client5.http.async.methods.SimpleHttpResponse; +import org.apache.hc.client5.http.config.RequestConfig; import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient; import org.apache.hc.client5.http.impl.async.HttpAsyncClients; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; @@ -66,6 +68,14 @@ public DefaultRestTransport(RestTransportOptions transportOptions) { httpClientAsync.setConnectionManager(asyncManager); } + if (transportOptions.timeout() != null) { + var config = RequestConfig.custom() + .setResponseTimeout(transportOptions.timeout().querySeconds(), TimeUnit.SECONDS) + .build(); + httpClient.setDefaultRequestConfig(config); + httpClientAsync.setDefaultRequestConfig(config); + } + if (transportOptions.tokenProvider() != null) { this.authInterceptor = new AuthenticationInterceptor(transportOptions.tokenProvider()); httpClient.addRequestInterceptorFirst(authInterceptor); @@ -101,6 +111,8 @@ private ClassicHttpRequest prepareClassicRequest(RequestT if (body != null) { req.setEntity(body, ContentType.APPLICATION_JSON); } + if (true) { + } return req.build(); } diff --git a/src/main/java/io/weaviate/client6/v1/internal/rest/RestTransportOptions.java b/src/main/java/io/weaviate/client6/v1/internal/rest/RestTransportOptions.java index 80f3299af..5da4cdd5f 100644 --- a/src/main/java/io/weaviate/client6/v1/internal/rest/RestTransportOptions.java +++ b/src/main/java/io/weaviate/client6/v1/internal/rest/RestTransportOptions.java @@ -8,6 +8,7 @@ import org.apache.hc.core5.http.message.BasicHeader; +import io.weaviate.client6.v1.internal.Timeout; import io.weaviate.client6.v1.internal.TokenProvider; import io.weaviate.client6.v1.internal.TransportOptions; @@ -15,8 +16,17 @@ public final class RestTransportOptions extends TransportOptions headers, - TokenProvider tokenProvider, TrustManagerFactory trust) { - super(scheme, host, port, buildHeaders(headers), tokenProvider, trust); + TokenProvider tokenProvider, TrustManagerFactory trust, Timeout timeout) { + super(scheme, host, port, buildHeaders(headers), tokenProvider, trust, timeout); + } + + private RestTransportOptions(String scheme, String host, int port, Collection headers, + TokenProvider tokenProvider, TrustManagerFactory trust, Timeout timeout) { + super(scheme, host, port, headers, tokenProvider, trust, timeout); + } + + public final RestTransportOptions withTimeout(Timeout timeout) { + return new RestTransportOptions(scheme, host, port, headers, tokenProvider, trustManagerFactory, timeout); } private static final Collection buildHeaders(Map headers) { diff --git a/src/test/java/io/weaviate/client6/v1/api/AuthenticationTest.java b/src/test/java/io/weaviate/client6/v1/api/AuthenticationTest.java index ea8531d48..54472875e 100644 --- a/src/test/java/io/weaviate/client6/v1/api/AuthenticationTest.java +++ b/src/test/java/io/weaviate/client6/v1/api/AuthenticationTest.java @@ -10,6 +10,7 @@ import org.mockserver.integration.ClientAndServer; import org.mockserver.model.HttpRequest; +import io.weaviate.client6.v1.internal.Timeout; import io.weaviate.client6.v1.internal.rest.DefaultRestTransport; import io.weaviate.client6.v1.internal.rest.RestTransport; import io.weaviate.client6.v1.internal.rest.RestTransportOptions; @@ -33,7 +34,7 @@ public void startMockServer() throws IOException { noAuthTransport = new DefaultRestTransport( new RestTransportOptions( "http", "localhost", mockServer.getLocalPort(), - Collections.emptyMap(), null, null)); + Collections.emptyMap(), null, null, new Timeout())); } @Test @@ -41,7 +42,7 @@ public void testAuthentication_apiKey() throws Exception { var authz = Authentication.apiKey("my-api-key"); var transportOptions = new RestTransportOptions( "http", "localhost", mockServer.getLocalPort(), - Collections.emptyMap(), authz.getTokenProvider(noAuthTransport), null); + Collections.emptyMap(), authz.getTokenProvider(noAuthTransport), null, new Timeout()); try (final var restClient = new DefaultRestTransport(transportOptions)) { restClient.performRequest(null, SimpleEndpoint.sideEffect( diff --git a/src/test/java/io/weaviate/client6/v1/api/WeaviateClientTest.java b/src/test/java/io/weaviate/client6/v1/api/WeaviateClientTest.java index e51bd66c3..3a0df26a9 100644 --- a/src/test/java/io/weaviate/client6/v1/api/WeaviateClientTest.java +++ b/src/test/java/io/weaviate/client6/v1/api/WeaviateClientTest.java @@ -14,7 +14,10 @@ public void testFailedConnection() { @Test(expected = WeaviateConnectException.class) public void testFailedConnection_Local() { - WeaviateClient.connectToLocal(); + try (final var __ = WeaviateClient.connectToLocal()) { + } catch (Exception e) { + throw new RuntimeException(e); + } } @Test(expected = WeaviateConnectException.class) diff --git a/src/test/java/io/weaviate/client6/v1/internal/rest/DefaultRestTransportTest.java b/src/test/java/io/weaviate/client6/v1/internal/rest/DefaultRestTransportTest.java index 28909df31..50551c176 100644 --- a/src/test/java/io/weaviate/client6/v1/internal/rest/DefaultRestTransportTest.java +++ b/src/test/java/io/weaviate/client6/v1/internal/rest/DefaultRestTransportTest.java @@ -13,6 +13,7 @@ import org.mockserver.integration.ClientAndServer; import org.mockserver.model.HttpRequest; +import io.weaviate.client6.v1.internal.Timeout; import io.weaviate.testutil.truststore.SingleTrustManagerFactory; import io.weaviate.testutil.truststore.SpyTrustManager; @@ -37,7 +38,7 @@ public void setUp() throws IOException { tmf = SingleTrustManagerFactory.create(new SpyTrustManager()); transport = new DefaultRestTransport(new RestTransportOptions( "https", "localhost", mockServer.getLocalPort(), - Collections.emptyMap(), null, tmf)); + Collections.emptyMap(), null, tmf, new Timeout())); } @Test From cd49613cb08b3225c905ba6e8dab3cacb2e8b0c1 Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Mon, 3 Nov 2025 18:50:34 +0100 Subject: [PATCH 02/15] fix: do not require collection name if CollectionHandle sub-methods --- .../v1/api/collections/config/WeaviateConfigClient.java | 4 ++-- .../v1/api/collections/config/WeaviateConfigClientAsync.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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 a5d72a3e5..33d50fb01 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 @@ -56,8 +56,8 @@ public void addReference(String propertyName, String... dataTypes) throws IOExce this.addProperty(ReferenceProperty.to(propertyName, dataTypes).toProperty()); } - public void update(String collectionName, - Function> fn) throws IOException { + public void update(Function> fn) + throws IOException { var thisCollection = get().orElseThrow(); // TODO: use descriptive error this.restTransport.performRequest(UpdateCollectionRequest.of(thisCollection, fn), UpdateCollectionRequest._ENDPOINT); 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 d0f0073b7..1c5d8f169 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 @@ -57,7 +57,7 @@ public CompletableFuture addReference(String name, String... dataTypes) th return this.addProperty(ReferenceProperty.to(name, dataTypes).toProperty()); } - public CompletableFuture update(String collectionName, + public CompletableFuture update( Function> fn) throws IOException { return get().thenCompose(maybeCollection -> { var thisCollection = maybeCollection.orElseThrow(); From 99f7b24f39dbbbdf6e1a590f4a34a7d35cf9ef6e Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Mon, 3 Nov 2025 18:55:25 +0100 Subject: [PATCH 03/15] chore: add useful overloads --- .../io/weaviate/integration/CollectionsITest.java | 2 +- .../v1/api/collections/data/WeaviateDataClient.java | 5 +++++ .../client6/v1/api/collections/query/Where.java | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/it/java/io/weaviate/integration/CollectionsITest.java b/src/it/java/io/weaviate/integration/CollectionsITest.java index 975ebba76..e9d1afa87 100644 --- a/src/it/java/io/weaviate/integration/CollectionsITest.java +++ b/src/it/java/io/weaviate/integration/CollectionsITest.java @@ -142,7 +142,7 @@ public void testUpdateCollection() throws IOException { var things = client.collections.use(nsThings); // Act - things.config.update(nsThings, collection -> collection + things.config.update(c -> c .description("Things stored on shelves") .propertyDescription("width", "not height") .invertedIndex(idx -> idx.cleanupIntervalSeconds(30)) diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/data/WeaviateDataClient.java b/src/main/java/io/weaviate/client6/v1/api/collections/data/WeaviateDataClient.java index 82cce27a6..be9cb5d4e 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/data/WeaviateDataClient.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/data/WeaviateDataClient.java @@ -64,6 +64,11 @@ public InsertManyResponse insertMany(List(objects)); } + @SafeVarargs + public final InsertManyResponse insertMany(WeaviateObject... objects) { + return insertMany(Arrays.asList(objects)); + } + public InsertManyResponse insertMany(InsertManyRequest request) { return this.grpcTransport.performRequest(request, InsertManyRequest.rpc(request.objects(), collection, defaults)); diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/query/Where.java b/src/main/java/io/weaviate/client6/v1/api/collections/query/Where.java index 56b49b927..74667a3f8 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/query/Where.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/query/Where.java @@ -438,6 +438,10 @@ public Where containsAny(String... values) { return new Where(Operator.CONTAINS_ANY, left, new TextArrayOperand(values)); } + public Where containsAny(List values) { + return new Where(Operator.CONTAINS_ANY, left, new TextArrayOperand(values)); + } + public Where containsAny(Boolean... values) { return new Where(Operator.CONTAINS_ANY, left, new BooleanArrayOperand(values)); } @@ -464,6 +468,10 @@ public Where containsAll(String... values) { return new Where(Operator.CONTAINS_ALL, left, new TextArrayOperand(values)); } + public Where containsAll(List values) { + return new Where(Operator.CONTAINS_ALL, left, new TextArrayOperand(values)); + } + public Where containsAll(Boolean... values) { return new Where(Operator.CONTAINS_ALL, left, new BooleanArrayOperand(values)); } @@ -490,6 +498,10 @@ public Where containsNone(String... values) { return new Where(Operator.CONTAINS_NONE, left, new TextArrayOperand(values)); } + public Where containsNone(List values) { + return new Where(Operator.CONTAINS_NONE, left, new TextArrayOperand(values)); + } + public Where containsNone(Boolean... values) { return new Where(Operator.CONTAINS_NONE, left, new BooleanArrayOperand(values)); } From 114912995218dab0c0da430d2ef1cfc27b9a99e9 Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Mon, 3 Nov 2025 23:50:09 +0100 Subject: [PATCH 04/15] feat: return CollectionHandle(-Async) from client.collections.create() --- .../io/weaviate/integration/SearchITest.java | 18 ++++-------- .../WeaviateCollectionsClient.java | 29 ++++++++++--------- .../WeaviateCollectionsClientAsync.java | 27 ++++++++--------- .../client6/v1/api/WeaviateClientTest.java | 15 ++++++---- 4 files changed, 45 insertions(+), 44 deletions(-) diff --git a/src/it/java/io/weaviate/integration/SearchITest.java b/src/it/java/io/weaviate/integration/SearchITest.java index 46a2ded83..59a7e3cc7 100644 --- a/src/it/java/io/weaviate/integration/SearchITest.java +++ b/src/it/java/io/weaviate/integration/SearchITest.java @@ -446,13 +446,12 @@ public void testBadRequest_async() throws Throwable { var nsThings = ns("Things"); try (final var async = client.async()) { - async.collections.create(nsThings, + var things = async.collections.create(nsThings, collection -> collection .properties(Property.text("name")) .vectorConfig(VectorConfig.text2vecContextionary())) .join(); - var things = async.collections.use(nsThings); var balloon = things.data.insert(Map.of("name", "balloon")).join(); try { @@ -467,13 +466,12 @@ public void testBadRequest_async() throws Throwable { public void testMetadataAll() throws IOException { // Arrange var nsThings = ns("Things"); - client.collections.create(nsThings, + var things = client.collections.create(nsThings, c -> c .properties(Property.text("name")) .vectorConfig(VectorConfig.text2vecContextionary( t2v -> t2v.sourceProperties("name")))); - var things = client.collections.use(nsThings); var frisbee = things.data.insert(Map.of("name", "orange disc")); // Act @@ -513,7 +511,7 @@ public void testNearVector_targetVectors() throws IOException { // Arrange var nsThings = ns("Things"); - client.collections.create(nsThings, + var things = client.collections.create(nsThings, c -> c.vectorConfig( VectorConfig.selfProvided("v1d"), VectorConfig.selfProvided("v2d", @@ -521,8 +519,6 @@ public void testNearVector_targetVectors() throws IOException { .vectorIndex(Hnsw.of( hnsw -> hnsw.multiVector(MultiVector.of())))))); - var things = client.collections.use(nsThings); - var thing123 = things.data.insert(Map.of(), thing -> thing.vectors( Vectors.of("v1d", new float[] { 1, 2, 3 }), Vectors.of("v2d", new float[][] { { 1, 2, 3 }, { 1, 2, 3 } }))); @@ -559,15 +555,13 @@ public void testGenerative_bm25() throws IOException { // Arrange var nsThings = ns("Things"); - client.collections.create(nsThings, + var things = client.collections.create(nsThings, c -> c .properties(Property.text("title")) .generativeModule(new DummyGenerative()) .vectorConfig(VectorConfig.text2vecContextionary( t2v -> t2v.sourceProperties("title")))); - var things = client.collections.use(nsThings); - things.data.insertMany( Map.of("title", "Salad Fork"), Map.of("title", "Dessert Fork")); @@ -600,15 +594,13 @@ public void testGenerative_bm25_groupBy() throws IOException { // Arrange var nsThings = ns("Things"); - client.collections.create(nsThings, + var things = client.collections.create(nsThings, c -> c .properties(Property.text("title")) .generativeModule(new DummyGenerative()) .vectorConfig(VectorConfig.text2vecContextionary( t2v -> t2v.sourceProperties("title")))); - var things = client.collections.use(nsThings); - things.data.insertMany( Map.of("title", "Salad Fork"), Map.of("title", "Dessert Fork")); diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/WeaviateCollectionsClient.java b/src/main/java/io/weaviate/client6/v1/api/collections/WeaviateCollectionsClient.java index b662dbd61..c0fca9bbc 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/WeaviateCollectionsClient.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/WeaviateCollectionsClient.java @@ -95,7 +95,7 @@ private CollectionHandle use(CollectionDescriptor * * @param cls Class that represents an object in the collection. - * @return the configuration of the created collection. + * @return Handle for the created collection. * @throws WeaviateApiException in case the server returned with an * error status code. * @throws IOException in case the request was not sent successfully @@ -104,9 +104,10 @@ private CollectionHandle use(CollectionDescriptor CollectionConfig create(Class cls) throws IOException { + public CollectionHandle create(Class cls) throws IOException { var collection = CollectionDescriptor.ofClass(cls); - return create(CollectionConfig.of(collection.collectionName(), collection.configFn())); + create(CollectionConfig.of(collection.collectionName(), collection.configFn())); + return use(cls); } /** @@ -115,7 +116,7 @@ public CollectionConfig create(Class c * * @param cls Class that represents an object in the collection. * @param fn Lamda expression for optional parameters. - * @return the configuration of the created collection. + * @return Handle for the created collection. * @throws WeaviateApiException in case the server returned with an * error status code. * @throws IOException in case the request was not sent successfully @@ -125,26 +126,27 @@ public CollectionConfig create(Class c * @see io.weaviate.client6.v1.api.collections.annotations.Property * @see WeaviateCollectionsClient#create(Class) */ - public CollectionConfig create( + public CollectionHandle create( Class cls, Function> fn) throws IOException { var collection = CollectionDescriptor.ofClass(cls); var configFn = ObjectBuilder.partial(fn, collection.configFn()); - return create(CollectionConfig.of(collection.collectionName(), configFn)); + create(CollectionConfig.of(collection.collectionName(), configFn)); + return use(cls); } /** * Create a new Weaviate collection with default configuration. * * @param collectionName Collection name. - * @return the configuration of the created collection. + * @return Handle for the created collection. * @throws WeaviateApiException in case the server returned with an * error status code. * @throws IOException in case the request was not sent successfully * due to a malformed request, a networking error * or the server being unavailable. */ - public CollectionConfig create(String collectionName) throws IOException { + public CollectionHandle> create(String collectionName) throws IOException { return create(CollectionConfig.of(collectionName)); } @@ -154,14 +156,14 @@ public CollectionConfig create(String collectionName) throws IOException { * * @param collectionName Collection name. * @param fn Lamda expression for optional parameters. - * @return the configuration of the created collection. + * @return Handle for the created collection. * @throws WeaviateApiException in case the server returned with an * error status code. * @throws IOException in case the request was not sent successfully * due to a malformed request, a networking error * or the server being unavailable. */ - public CollectionConfig create(String collectionName, + public CollectionHandle> create(String collectionName, Function> fn) throws IOException { return create(CollectionConfig.of(collectionName, fn)); } @@ -169,16 +171,17 @@ public CollectionConfig create(String collectionName, /** * Create a new Weaviate collection with {@link CollectionConfig}. * - * @return the configuration of the created collection. + * @return Handle for the created collection. * @throws WeaviateApiException in case the server returned with an * error status code. * @throws IOException in case the request was not sent successfully * due to a malformed request, a networking error * or the server being unavailable. */ - public CollectionConfig create(CollectionConfig collection) throws IOException { - return this.restTransport.performRequest(new CreateCollectionRequest(collection), + public CollectionHandle> create(CollectionConfig collection) throws IOException { + this.restTransport.performRequest(new CreateCollectionRequest(collection), CreateCollectionRequest._ENDPOINT); + return use(collection.collectionName()); } /** diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/WeaviateCollectionsClientAsync.java b/src/main/java/io/weaviate/client6/v1/api/collections/WeaviateCollectionsClientAsync.java index 8f5c3516c..ba80f715e 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/WeaviateCollectionsClientAsync.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/WeaviateCollectionsClientAsync.java @@ -26,8 +26,7 @@ public WeaviateCollectionsClientAsync(RestTransport restTransport, GrpcTransport * The returned object is thread-safe. * * @param cls Class that represents an object in the collection. - * @return a handle for a collection with {@code Class} - * properties. + * @return a handle for a collection with {@code PropertiesT} properties. */ public CollectionHandleAsync use(Class cls) { return use(CollectionDescriptor.ofClass(cls), CollectionHandleDefaults.none()); @@ -39,8 +38,7 @@ public CollectionHandleAsync use(Class * * @param cls Class that represents an object in the collection. * @param fn Lamda expression for optional parameters. - * @return a handle for a collection with {@code Class} - * properties. + * @return a handle for a collection with {@code PropertiesT} properties. */ public CollectionHandleAsync use( Class cls, @@ -98,9 +96,11 @@ private CollectionHandleAsync use(CollectionDescripto * @see io.weaviate.client6.v1.api.collections.annotations.Collection * @see io.weaviate.client6.v1.api.collections.annotations.Property */ - public CompletableFuture create(Class cls) { + public CompletableFuture> create( + Class cls) { var collection = CollectionDescriptor.ofClass(cls); - return create(CollectionConfig.of(collection.collectionName(), collection.configFn())); + return create(CollectionConfig.of(collection.collectionName(), collection.configFn())) + .thenApply(__ -> use(cls)); } /** @@ -113,20 +113,21 @@ public CompletableFuture create(C * @see io.weaviate.client6.v1.api.collections.annotations.Property * @see WeaviateCollectionsClientAsync#create(Class) */ - public CompletableFuture create(Class cls, + public CompletableFuture> create( + Class cls, Function> fn) { var collection = CollectionDescriptor.ofClass(cls); var configFn = ObjectBuilder.partial(fn, collection.configFn()); - return create(CollectionConfig.of(collection.collectionName(), configFn)); + return create(CollectionConfig.of(collection.collectionName(), configFn)) + .thenApply(__ -> use(cls)); } /** * Create a new Weaviate collection with default configuration. * * @param collectionName Collection name. - * @return the configuration of the created collection. */ - public CompletableFuture create(String collectionName) { + public CompletableFuture>> create(String collectionName) { return create(CollectionConfig.of(collectionName)); } @@ -137,7 +138,7 @@ public CompletableFuture create(String collectionName) { * @param collectionName Collection name. * @param fn Lamda expression for optional parameters. */ - public CompletableFuture create(String collectionName, + public CompletableFuture>> create(String collectionName, Function> fn) { return create(CollectionConfig.of(collectionName, fn)); } @@ -145,9 +146,9 @@ public CompletableFuture create(String collectionName, /** * Create a new Weaviate collection with {@link CollectionConfig}. */ - public CompletableFuture create(CollectionConfig collection) { + public CompletableFuture>> create(CollectionConfig collection) { return this.restTransport.performRequestAsync(new CreateCollectionRequest(collection), - CreateCollectionRequest._ENDPOINT); + CreateCollectionRequest._ENDPOINT).thenApply(__ -> use(collection.collectionName())); } /** diff --git a/src/test/java/io/weaviate/client6/v1/api/WeaviateClientTest.java b/src/test/java/io/weaviate/client6/v1/api/WeaviateClientTest.java index 3a0df26a9..900d60bb9 100644 --- a/src/test/java/io/weaviate/client6/v1/api/WeaviateClientTest.java +++ b/src/test/java/io/weaviate/client6/v1/api/WeaviateClientTest.java @@ -13,11 +13,16 @@ public void testFailedConnection() { } @Test(expected = WeaviateConnectException.class) - public void testFailedConnection_Local() { - try (final var __ = WeaviateClient.connectToLocal()) { - } catch (Exception e) { - throw new RuntimeException(e); - } + public void testFailedConnection_Local() throws Exception { + // This test will fail if SOME Weaviate container is running on your machine + // with default :8080 port exposed. All Testcontainer instances started by + // the client's test suite expose random ports, which will not interferen with + // this test. + // + // You might also see a warning from gRPC saying that the channel has been + // garbage-collected before it was closed. The stack trace will probably + // show that it's related to this test. + WeaviateClient.connectToLocal(); } @Test(expected = WeaviateConnectException.class) From fb7b25cd2e49934fba234718254720cf991abfcd Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Tue, 4 Nov 2025 00:13:30 +0100 Subject: [PATCH 05/15] feat: provide overload for includeVector to fetch named vectors --- .../io/weaviate/integration/SearchITest.java | 28 +++++++ .../client6/v1/api/collections/Vectors.java | 9 +++ .../collections/query/BaseQueryOptions.java | 73 +++++++++++-------- .../v1/api/collections/query/ById.java | 19 ++++- 4 files changed, 98 insertions(+), 31 deletions(-) diff --git a/src/it/java/io/weaviate/integration/SearchITest.java b/src/it/java/io/weaviate/integration/SearchITest.java index 59a7e3cc7..77306c7db 100644 --- a/src/it/java/io/weaviate/integration/SearchITest.java +++ b/src/it/java/io/weaviate/integration/SearchITest.java @@ -462,6 +462,34 @@ public void testBadRequest_async() throws Throwable { } } + @Test + public void test_includeVectors() throws IOException { + // Arrange + var nsThings = ns("Things"); + var things = client.collections.create(nsThings, + c -> c.vectorConfig( + VectorConfig.selfProvided("v1"), + VectorConfig.selfProvided("v2"), + VectorConfig.selfProvided("v3"))); + + var thing_1 = things.data.insert(Map.of(), thing -> thing.vectors( + Vectors.of("v1", new float[] { 1, 2, 3 }), + Vectors.of("v2", new float[] { 4, 5, 6 }), + Vectors.of("v3", new float[] { 7, 8, 9 }))); + + // Act + var got = things.query.byId( + thing_1.uuid(), + q -> q.includeVector("v1", "v2")); + + // Assert + Assertions.assertThat(got).get() + .extracting(WeaviateObject::vectors) + .returns(true, v -> v.contains("v1")) + .returns(true, v -> v.contains("v2")) + .returns(false, v -> v.contains("v3")); + } + @Test public void testMetadataAll() throws IOException { // Arrange diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/Vectors.java b/src/main/java/io/weaviate/client6/v1/api/collections/Vectors.java index d255a3191..a1e9e8796 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/Vectors.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/Vectors.java @@ -81,6 +81,15 @@ public Vectors(Vectors... vectors) { this.vectorsMap = namedVectors; } + /** + * Check if a vector exists in the query result. + * + * @param name Vector name. + */ + public boolean contains(String name) { + return vectorsMap.containsKey(name); + } + /** * Get 1-dimensional vector by name. * diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/query/BaseQueryOptions.java b/src/main/java/io/weaviate/client6/v1/api/collections/query/BaseQueryOptions.java index e7f433dea..dc145f690 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/query/BaseQueryOptions.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/query/BaseQueryOptions.java @@ -23,7 +23,8 @@ public record BaseQueryOptions( GenerativeSearch generativeSearch, List returnProperties, List returnReferences, - List returnMetadata) { + List returnMetadata, + List includeVectors) { private BaseQueryOptions(Builder, T> builder) { this( @@ -36,12 +37,13 @@ private BaseQueryOptions(Builder, T> builder.generativeSearch, builder.returnProperties, builder.returnReferences, - builder.returnMetadata); + builder.returnMetadata, + builder.includeVectors); } @SuppressWarnings("unchecked") - public static abstract class Builder, T extends Object> implements ObjectBuilder { + public static abstract class Builder, T extends Object> implements ObjectBuilder { private Integer limit; private Integer offset; private Integer autocut; @@ -52,6 +54,7 @@ public static abstract class Builder, T extends Ob private List returnProperties = new ArrayList<>(); private List returnReferences = new ArrayList<>(); private List returnMetadata = new ArrayList<>(); + private List includeVectors = new ArrayList<>(); protected Builder() { returnMetadata(MetadataField.UUID); @@ -63,9 +66,9 @@ protected Builder() { *

* Combine with {@link #offset(int)} to use offset-based pagination. */ - public final SELF limit(int limit) { + public final SelfT limit(int limit) { this.limit = limit; - return (SELF) this; + return (SelfT) this; } /** @@ -74,9 +77,9 @@ public final SELF limit(int limit) { *

* Combine with {@link #limit(int)} to use offset-based pagination. */ - public final SELF offset(int offset) { + public final SelfT offset(int offset) { this.offset = offset; - return (SELF) this; + return (SelfT) this; } /** @@ -86,9 +89,9 @@ public final SELF offset(int offset) { * @see Documentation */ - public final SELF autocut(int autocut) { + public final SelfT autocut(int autocut) { this.autocut = autocut; - return (SELF) this; + return (SelfT) this; } /** @@ -96,15 +99,15 @@ public final SELF autocut(int autocut) { * * @param after UUID of an object in this collection. */ - public final SELF after(String after) { + public final SelfT after(String after) { this.after = after; - return (SELF) this; + return (SelfT) this; } /** Set consitency level for query resolution. */ - public final SELF consistencyLevel(ConsistencyLevel consistencyLevel) { + public final SelfT consistencyLevel(ConsistencyLevel consistencyLevel) { this.consistencyLevel = consistencyLevel; - return (SELF) this; + return (SelfT) this; } /** @@ -113,9 +116,9 @@ public final SELF consistencyLevel(ConsistencyLevel consistencyLevel) { * * @param fn Lambda expression for optional parameters. */ - protected SELF generate(Function> fn) { + protected SelfT generate(Function> fn) { this.generativeSearch = GenerativeSearch.of(fn); - return (SELF) this; + return (SelfT) this; } /** @@ -123,55 +126,66 @@ protected SELF generate(Function properties) { + public final SelfT returnProperties(List properties) { this.returnProperties.addAll(properties); - return (SELF) this; + return (SelfT) this; } /** Select cross-referenced objects to include in the query result. */ - public final SELF returnReferences(QueryReference... references) { + public final SelfT returnReferences(QueryReference... references) { return returnReferences(Arrays.asList(references)); } /** Select cross-referenced objects to include in the query result. */ - public final SELF returnReferences(List references) { + public final SelfT returnReferences(List references) { this.returnReferences.addAll(references); - return (SELF) this; + return (SelfT) this; } /** Select metadata to include in the query result. */ - public final SELF returnMetadata(Metadata... metadata) { + public final SelfT returnMetadata(Metadata... metadata) { return returnMetadata(Arrays.asList(metadata)); } /** Select metadata to include in the query result. */ - public final SELF returnMetadata(List metadata) { + public final SelfT returnMetadata(List metadata) { this.returnMetadata.addAll(metadata); - return (SELF) this; + return (SelfT) this; } /** Include default vector. */ - public final SELF includeVector() { + public final SelfT includeVector() { return returnMetadata(Metadata.VECTOR); } + /** Include one or more named vectors in the metadata response. */ + public final SelfT includeVector(String... vectors) { + return includeVector(Arrays.asList(vectors)); + } + + /** Include one or more named vectors in the metadata response. */ + public final SelfT includeVector(List vectors) { + this.includeVectors.addAll(vectors); + return (SelfT) this; + } + final BaseQueryOptions baseOptions() { return _build(); } @@ -218,6 +232,7 @@ final void appendTo(WeaviateProtoSearchGet.SearchRequest.Builder req) { var metadata = WeaviateProtoSearchGet.MetadataRequest.newBuilder(); returnMetadata.forEach(m -> m.appendTo(metadata)); + metadata.addAllVectors(includeVectors); req.setMetadata(metadata); if (!returnProperties.isEmpty() || !returnReferences.isEmpty()) { diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/query/ById.java b/src/main/java/io/weaviate/client6/v1/api/collections/query/ById.java index 7beb43f90..86b39f9e7 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/query/ById.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/query/ById.java @@ -16,7 +16,8 @@ public record ById( String uuid, List returnProperties, List returnReferences, - List returnMetadata) implements QueryOperator { + List returnMetadata, + List includeVectors) implements QueryOperator { static final String ID_PROPERTY = "_id"; @@ -32,7 +33,8 @@ public ById(Builder builder) { this(builder.uuid, new ArrayList<>(builder.returnProperties), builder.returnReferences, - new ArrayList<>(builder.returnMetadata)); + new ArrayList<>(builder.returnMetadata), + builder.includeVectors); } public static class Builder implements ObjectBuilder { @@ -42,6 +44,7 @@ public static class Builder implements ObjectBuilder { private Set returnProperties = new HashSet<>(); private List returnReferences = new ArrayList<>(); private Set returnMetadata = new HashSet<>(); + private List includeVectors = new ArrayList<>(); public Builder(String uuid) { this.uuid = uuid; @@ -86,6 +89,17 @@ public final Builder includeVector() { return returnMetadata(Metadata.VECTOR); } + /** Include one or more named vectors in the metadata response. */ + public final Builder includeVector(String... vectors) { + return includeVector(Arrays.asList(vectors)); + } + + /** Include one or more named vectors in the metadata response. */ + public final Builder includeVector(List vectors) { + this.includeVectors.addAll(vectors); + return this; + } + @Override public ById build() { return new ById(this); @@ -101,6 +115,7 @@ public void appendTo(WeaviateProtoSearchGet.SearchRequest.Builder req) { var metadata = WeaviateProtoSearchGet.MetadataRequest.newBuilder(); returnMetadata.forEach(m -> m.appendTo(metadata)); + metadata.addAllVectors(includeVectors); req.setMetadata(metadata); if (!returnProperties.isEmpty() || !returnReferences.isEmpty()) { From 3dbe975fd3793f622a3761fea7f62b36a8137371 Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Tue, 4 Nov 2025 00:15:37 +0100 Subject: [PATCH 06/15] feat: allow overAll aggregation with only the GroupBy argument --- .../aggregate/AbstractAggregateClient.java | 16 ++++++++++++++++ .../api/collections/aggregate/Aggregation.java | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java b/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java index da41349a8..a9c80a00c 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java @@ -60,6 +60,22 @@ public ResponseT overAll(Function returnMetrics) { + public static Aggregation of() { + return of(AggregateObjectFilter.NONE, ObjectBuilder.identity()); + } + public static Aggregation of(Function> fn) { return of(AggregateObjectFilter.NONE, fn); } From c03971979c4d92297775db1fb44ea798f2aa0da5 Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Tue, 4 Nov 2025 00:34:32 +0100 Subject: [PATCH 07/15] chore: rename TEXT metrics to correspond to Python --- .../collections/aggregate/TextAggregation.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/TextAggregation.java b/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/TextAggregation.java index 1bd8b6ed0..1d34afb7e 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/TextAggregation.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/TextAggregation.java @@ -35,7 +35,11 @@ public Builder(String property) { super(property); } - public final Builder count() { + /** + * Include the number of occurrences (frequency count) for each top most + * occuring value in the results. + */ + public final Builder topOccurrencesCount() { return addMetric(WeaviateProtoAggregate.AggregateRequest.Aggregation.Text.Builder::setCount); } @@ -43,13 +47,19 @@ public Builder type() { return addMetric(WeaviateProtoAggregate.AggregateRequest.Aggregation.Text.Builder::setType); } - public Builder topOccurences() { + /** + * Include the value of the top occurrences in the aggregation results. + */ + public Builder topOccurrencesValue() { return addMetric(WeaviateProtoAggregate.AggregateRequest.Aggregation.Text.Builder::setTopOccurences); } - public Builder topOccurencesCutoff(int cutoff) { + /** + * Set a minimum cutoff point after which groups should be discarded. + */ + public Builder minOccurrences(int cutoff) { this.topOccurrencesCutoff = cutoff; - return topOccurences(); + return topOccurrencesCount(); } @Override From 62c46a72ee834802099ed1dcdb4f69d6c2ce5137 Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Tue, 4 Nov 2025 11:25:19 +0100 Subject: [PATCH 08/15] feat: support pagination with filters --- .../client6/v1/api/collections/pagination/Paginator.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/pagination/Paginator.java b/src/main/java/io/weaviate/client6/v1/api/collections/pagination/Paginator.java index 7d7dcb6f9..b5de3a370 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/pagination/Paginator.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/pagination/Paginator.java @@ -14,6 +14,7 @@ import io.weaviate.client6.v1.api.collections.query.QueryMetadata; import io.weaviate.client6.v1.api.collections.query.QueryReference; import io.weaviate.client6.v1.api.collections.query.WeaviateQueryClient; +import io.weaviate.client6.v1.api.collections.query.Where; import io.weaviate.client6.v1.internal.ObjectBuilder; public class Paginator implements Iterable> { @@ -88,6 +89,11 @@ public Builder fromCursor(String uuid) { // Query options ---------------------------------------------------------- + /** Combine several conditions using with an AND operator. */ + public final Builder where(Where... where) { + return applyQueryOption(q -> q.where(where)); + } + public final Builder returnProperties(String... properties) { return applyQueryOption(q -> q.returnProperties(properties)); } From a1a939e2bb5f9f384e763d5d12b5d029b10038be Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Tue, 4 Nov 2025 11:28:56 +0100 Subject: [PATCH 09/15] feat: add 'cache' parameter for RQ --- .../client6/v1/api/collections/quantizers/RQ.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/quantizers/RQ.java b/src/main/java/io/weaviate/client6/v1/api/collections/quantizers/RQ.java index 0b4151e08..43dbfb2e0 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/quantizers/RQ.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/quantizers/RQ.java @@ -10,7 +10,8 @@ public record RQ( @SerializedName("enabled") boolean enabled, @SerializedName("rescore_limit") Integer rescoreLimit, - @SerializedName("bits") Integer bits) implements Quantization { + @SerializedName("bits") Integer bits, + @SerializedName("cache") Boolean cache) implements Quantization { @Override public Quantization.Kind _kind() { @@ -31,13 +32,14 @@ public static RQ of(Function> fn) { } public RQ(Builder builder) { - this(builder.enabled, builder.rescoreLimit, builder.bits); + this(builder.enabled, builder.rescoreLimit, builder.bits, builder.cache); } public static class Builder implements ObjectBuilder { private boolean enabled = true; private Integer rescoreLimit; private Integer bits; + private Boolean cache; public Builder enabled(boolean enabled) { this.enabled = enabled; @@ -54,6 +56,11 @@ public Builder bits(int bits) { return this; } + public Builder cache(boolean enabled) { + this.cache = enabled; + return this; + } + @Override public RQ build() { return new RQ(this); From 78701bf71860830eb8f9c94192781b2c20a858d4 Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Tue, 4 Nov 2025 11:37:03 +0100 Subject: [PATCH 10/15] feat: add Target to aggregate-hybrid queries --- .../aggregate/AbstractAggregateClient.java | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java b/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java index a9c80a00c..0dcf41629 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java @@ -110,6 +110,21 @@ public ResponseT hybrid(String query, Function> fn) { + return hybrid(Hybrid.of(searchTarget), fn); + } + /** * Aggregate results of a hybrid search query. * @@ -127,6 +142,23 @@ public ResponseT hybrid(String query, Function> hybrid, + Function> fn) { + return hybrid(Hybrid.of(searchTarget, hybrid), fn); + } + /** * Aggregate results of a hybrid search query. * @@ -161,6 +193,25 @@ public GroupedResponseT hybrid(String query, Function> fn, + GroupBy groupBy) { + return hybrid(Hybrid.of(searchTarget), fn, groupBy); + } + /** * Aggregate results of a hybrid search query. * @@ -181,6 +232,26 @@ public GroupedResponseT hybrid(String query, Function> hybrid, + Function> fn, GroupBy groupBy) { + return hybrid(Hybrid.of(searchTarget, hybrid), fn, groupBy); + } + /** * Aggregate results of a hybrid search query. * From ad1f62a6065e04adb182af127787f63dabaacff2 Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Tue, 4 Nov 2025 11:39:36 +0100 Subject: [PATCH 11/15] feat: add nearVector overloads for float[][] input --- .../aggregate/AbstractAggregateClient.java | 71 +++++++++++++++++++ .../generate/AbstractGenerateClient.java | 68 ++++++++++++++++++ .../query/AbstractQueryClient.java | 57 +++++++++++++++ 3 files changed, 196 insertions(+) diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java b/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java index 0dcf41629..850d88c16 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java @@ -305,6 +305,38 @@ public ResponseT nearVector(float[] vector, Function> fn) { + return nearVector(NearVector.of(Target.vector(vector)), fn); + } + + /** + * Aggregate results of a near vector query. + * + * @param vector Query vector. + * @param nv Lambda expression for optional near vector parameters. + * @param fn Lambda expression for optional aggregation parameters. + * @return Aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * @see AggregateResponse + */ + public ResponseT nearVector(float[][] vector, Function> nv, + Function> fn) { + return nearVector(NearVector.of(Target.vector(vector), nv), fn); + } + /** * Aggregate results of a near vector query. * @@ -359,6 +391,45 @@ public GroupedResponseT nearVector(float[] vector, Function> fn, + GroupBy groupBy) { + return nearVector(NearVector.of(Target.vector(vector)), fn, groupBy); + } + + /** + * Aggregate results of a near vector query. + * + * @param vector Query vector. + * @param nv Lambda expression for optional near vector parameters. + * @param fn Lambda expression for optional aggregation parameters. + * @param groupBy GroupBy clause. + * @return Grouped aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * + * @see GroupBy + * @see AggregateResponseGrouped + */ + public GroupedResponseT nearVector(float[][] vector, Function> nv, + Function> fn, GroupBy groupBy) { + return nearVector(NearVector.of(Target.vector(vector), nv), fn, groupBy); + } + /** * Aggregate results of a near vector query. * diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/generate/AbstractGenerateClient.java b/src/main/java/io/weaviate/client6/v1/api/collections/generate/AbstractGenerateClient.java index c2ef15ea1..cb80eb75c 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/generate/AbstractGenerateClient.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/generate/AbstractGenerateClient.java @@ -419,6 +419,34 @@ public ResponseT nearVector(float[] vector, return nearVector(Target.vector(vector), fn, generateFn); } + /** + * Run a generative task on the results of a near vector search. + * + * @param vector Query vector. + * @param generateFn Lambda expression for generative task parameters. + * @throws WeaviateApiException in case the server returned with an + * error status code. + */ + public ResponseT nearVector(float[][] vector, + Function> generateFn) { + return nearVector(Target.vector(vector), generateFn); + } + + /** + * Run a generative task on the results of a near vector search. + * + * @param vector Query vector. + * @param fn Lambda expression for optional search parameters. + * @param generateFn Lambda expression for generative task parameters. + * @throws WeaviateApiException in case the server returned with an + * error status code. + */ + public ResponseT nearVector(float[][] vector, + Function> fn, + Function> generateFn) { + return nearVector(Target.vector(vector), fn, generateFn); + } + /** * Run a generative task on the results of a near vector search. * @@ -499,6 +527,46 @@ public GroupedResponseT nearVector(float[] vector, return nearVector(Target.vector(vector), fn, generateFn, groupBy); } + /** + * Run a generative task on the results of a near vector search. + * + * @param vector Query vector. + * @param generateFn Lambda expression for generative task parameters. + * @param groupBy Group-by clause. + * @return Grouped query result. + * @throws WeaviateApiException in case the server returned with an + * error status code. + * + * @see GroupBy + * @see GenerativeResponseGrouped + */ + public GroupedResponseT nearVector(float[][] vector, + Function> generateFn, + GroupBy groupBy) { + return nearVector(Target.vector(vector), generateFn, groupBy); + } + + /** + * Run a generative task on the results of a near vector search. + * + * @param vector Query vector. + * @param fn Lambda expression for optional search parameters. + * @param generateFn Lambda expression for generative task parameters. + * @param groupBy Group-by clause. + * @return Grouped query result. + * @throws WeaviateApiException in case the server returned with an + * error status code. + * + * @see GroupBy + * @see GenerativeResponseGrouped + */ + public GroupedResponseT nearVector(float[][] vector, + Function> fn, + Function> generateFn, + GroupBy groupBy) { + return nearVector(Target.vector(vector), fn, generateFn, groupBy); + } + /** * Run a generative task on the results of a near vector search. * diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/query/AbstractQueryClient.java b/src/main/java/io/weaviate/client6/v1/api/collections/query/AbstractQueryClient.java index 36abd514c..99ee83fd6 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/query/AbstractQueryClient.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/query/AbstractQueryClient.java @@ -415,6 +415,29 @@ public ResponseT nearVector(float[] vector, Function> fn) { + return nearVector(Target.vector(vector), fn); + } + /** * Query collection objects using near vector search. * @@ -484,6 +507,40 @@ public GroupedResponseT nearVector(float[] vector, Function> fn, + GroupBy groupBy) { + return nearVector(Target.vector(vector), fn, groupBy); + } + /** * Query collection objects using near vector search. * From 593dcc98d0775ec29680a913a4231f9de80c33ea Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Tue, 4 Nov 2025 11:57:32 +0100 Subject: [PATCH 12/15] feat: add Target to aggregate-nearVector queries --- .../aggregate/AbstractAggregateClient.java | 109 ++++++++++++++++-- 1 file changed, 98 insertions(+), 11 deletions(-) diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java b/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java index 850d88c16..afa76cd4d 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java @@ -14,6 +14,7 @@ import io.weaviate.client6.v1.api.collections.query.NearText; import io.weaviate.client6.v1.api.collections.query.NearThermal; import io.weaviate.client6.v1.api.collections.query.NearVector; +import io.weaviate.client6.v1.api.collections.query.NearVectorTarget; import io.weaviate.client6.v1.api.collections.query.NearVideo; import io.weaviate.client6.v1.api.collections.query.Target; import io.weaviate.client6.v1.internal.ObjectBuilder; @@ -284,7 +285,8 @@ public GroupedResponseT hybrid(Hybrid filter, Function> fn) { + public ResponseT nearVector(float[] vector, + Function> fn) { return nearVector(NearVector.of(Target.vector(vector)), fn); } @@ -300,7 +302,8 @@ public ResponseT nearVector(float[] vector, Function> nv, + public ResponseT nearVector(float[] vector, + Function> nv, Function> fn) { return nearVector(NearVector.of(Target.vector(vector), nv), fn); } @@ -332,11 +335,46 @@ public ResponseT nearVector(float[][] vector, Function> nv, + public ResponseT nearVector(float[][] vector, + Function> nv, Function> fn) { return nearVector(NearVector.of(Target.vector(vector), nv), fn); } + /** + * Aggregate results of a near vector query. + * + * @param searchTarget Query target. + * @param fn Lambda expression for optional aggregation parameters. + * @return Aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * @see AggregateResponse + */ + public ResponseT nearVector(NearVectorTarget searchTarget, + Function> fn) { + return nearVector(NearVector.of(searchTarget), fn); + } + + /** + * Aggregate results of a near vector query. + * + * @param searchTarget Query target. + * @param nv Lambda expression for optional near vector parameters. + * @param fn Lambda expression for optional aggregation parameters. + * @return Aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * @see AggregateResponse + */ + public ResponseT nearVector(NearVectorTarget searchTarget, + Function> nv, + Function> fn) { + return nearVector(NearVector.of(searchTarget), fn); + } + /** * Aggregate results of a near vector query. * @@ -348,7 +386,8 @@ public ResponseT nearVector(float[][] vector, Function> fn) { + public ResponseT nearVector(NearVector filter, + Function> fn) { return performRequest(Aggregation.of(filter, fn)); } @@ -366,7 +405,8 @@ public ResponseT nearVector(NearVector filter, Function> fn, + public GroupedResponseT nearVector(float[] vector, + Function> fn, GroupBy groupBy) { return nearVector(NearVector.of(Target.vector(vector)), fn, groupBy); } @@ -386,8 +426,10 @@ public GroupedResponseT nearVector(float[] vector, Function> nv, - Function> fn, GroupBy groupBy) { + public GroupedResponseT nearVector(float[] vector, + Function> nv, + Function> fn, + GroupBy groupBy) { return nearVector(NearVector.of(Target.vector(vector), nv), fn, groupBy); } @@ -405,7 +447,8 @@ public GroupedResponseT nearVector(float[] vector, Function> fn, + public GroupedResponseT nearVector(float[][] vector, + Function> fn, GroupBy groupBy) { return nearVector(NearVector.of(Target.vector(vector)), fn, groupBy); } @@ -425,11 +468,54 @@ public GroupedResponseT nearVector(float[][] vector, Function> nv, - Function> fn, GroupBy groupBy) { + public GroupedResponseT nearVector(float[][] vector, + Function> nv, + Function> fn, + GroupBy groupBy) { return nearVector(NearVector.of(Target.vector(vector), nv), fn, groupBy); } + /** + * Aggregate results of a near vector query. + * + * @param searchTarget Query target. + * @param fn Lambda expression for optional aggregation parameters. + * @param groupBy GroupBy clause. + * @return Grouped aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * + * @see GroupBy + * @see AggregateResponseGrouped + */ + public GroupedResponseT nearVector(NearVectorTarget searchTarget, + Function> fn, + GroupBy groupBy) { + return nearVector(NearVector.of(searchTarget), fn, groupBy); + } + + /** + * Aggregate results of a near vector query. + * + * @param searchTarget Query target. + * @param nv Lambda expression for optional near vector parameters. + * @param fn Lambda expression for optional aggregation parameters. + * @param groupBy GroupBy clause. + * @return Grouped aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * + * @see GroupBy + * @see AggregateResponseGrouped + */ + public GroupedResponseT nearVector(NearVectorTarget searchTarget, + Function> nv, + Function> fn, GroupBy groupBy) { + return nearVector(NearVector.of(searchTarget, nv), fn, groupBy); + } + /** * Aggregate results of a near vector query. * @@ -444,7 +530,8 @@ public GroupedResponseT nearVector(float[][] vector, Function> fn, + public GroupedResponseT nearVector(NearVector filter, + Function> fn, GroupBy groupBy) { return performRequest(Aggregation.of(filter, fn), groupBy); } From 91fe45dd6db8499864121c49d138af1102a154cf Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Tue, 4 Nov 2025 12:05:55 +0100 Subject: [PATCH 13/15] feat: add Target to aggregate-nearText queries --- .../aggregate/AbstractAggregateClient.java | 102 ++++++++++++++++-- 1 file changed, 93 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java b/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java index afa76cd4d..5f7119225 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java @@ -675,6 +675,21 @@ public ResponseT nearText(List concepts, Function> fn) { + return nearText(NearText.of(searchTarget), fn); + } + /** * Aggregate results of a near text query. * @@ -687,7 +702,8 @@ public ResponseT nearText(List concepts, Function> nt, + public ResponseT nearText(String text, + Function> nt, Function> fn) { return nearText(NearText.of(Target.text(List.of(text)), nt), fn); } @@ -704,11 +720,30 @@ public ResponseT nearText(String text, Function concepts, Function> nt, + public ResponseT nearText(List concepts, + Function> nt, Function> fn) { return nearText(NearText.of(Target.text(concepts), nt), fn); } + /** + * Aggregate results of a near text query. + * + * @param searchTarget Query target. + * @param nt Lambda expression for optional near text parameters. + * @param fn Lambda expression for optional aggregation parameters. + * @return Aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * @see AggregateResponse + */ + public ResponseT nearText(Target searchTarget, + Function> nt, + Function> fn) { + return nearText(NearText.of(searchTarget, nt), fn); + } + /** * Aggregate results of a near text query. * @@ -719,7 +754,8 @@ public ResponseT nearText(List concepts, Function> fn) { + public ResponseT nearText(NearText filter, + Function> fn) { return performRequest(Aggregation.of(filter, fn)); } @@ -737,7 +773,8 @@ public ResponseT nearText(NearText filter, Function> fn, + public GroupedResponseT nearText(String text, + Function> fn, GroupBy groupBy) { return nearText(NearText.of(text), fn, groupBy); } @@ -756,11 +793,32 @@ public GroupedResponseT nearText(String text, Function concepts, Function> fn, + public GroupedResponseT nearText(List concepts, + Function> fn, GroupBy groupBy) { return nearText(NearText.of(Target.text(concepts)), fn, groupBy); } + /** + * Aggregate results of a near text query. + * + * @param searchTarget Query target. + * @param fn Lambda expression for optional aggregation parameters. + * @param groupBy GroupBy clause. + * @return Grouped aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * + * @see GroupBy + * @see AggregateResponseGrouped + */ + public GroupedResponseT nearText(Target searchTarget, + Function> fn, + GroupBy groupBy) { + return nearText(NearText.of(searchTarget), fn, groupBy); + } + /** * Aggregate results of a near text query. * @@ -776,8 +834,10 @@ public GroupedResponseT nearText(List concepts, Function> nt, - Function> fn, GroupBy groupBy) { + public GroupedResponseT nearText(String text, + Function> nt, + Function> fn, + GroupBy groupBy) { return nearText(NearText.of(text, nt), fn, groupBy); } @@ -796,11 +856,35 @@ public GroupedResponseT nearText(String text, Function concepts, Function> nt, - Function> fn, GroupBy groupBy) { + public GroupedResponseT nearText(List concepts, + Function> nt, + Function> fn, + GroupBy groupBy) { return nearText(NearText.of(Target.text(concepts), nt), fn, groupBy); } + /** + * Aggregate results of a near text query. + * + * @param searchTarget Query target. + * @param nt Lambda expression for optional near text parameters. + * @param fn Lambda expression for optional aggregation parameters. + * @param groupBy GroupBy clause. + * @return Grouped aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * + * @see GroupBy + * @see AggregateResponseGrouped + */ + public GroupedResponseT nearText(Target searchTarget, + Function> nt, + Function> fn, + GroupBy groupBy) { + return nearText(NearText.of(searchTarget, nt), fn, groupBy); + } + /** * Aggregate results of a near text query. * From dacac3e17d82efd581fb4dcf118f283afa86104e Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Tue, 4 Nov 2025 12:20:17 +0100 Subject: [PATCH 14/15] feat: add Target to aggregate-media queries --- .../aggregate/AbstractAggregateClient.java | 471 +++++++++++++++++- 1 file changed, 466 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java b/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java index 5f7119225..8d36dbcbb 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/aggregate/AbstractAggregateClient.java @@ -917,7 +917,8 @@ public GroupedResponseT nearText(NearText filter, Function> fn) { + public ResponseT nearImage(String image, + Function> fn) { return nearImage(NearImage.of(image), fn); } @@ -933,11 +934,46 @@ public ResponseT nearImage(String image, Function> ni, + public ResponseT nearImage(String image, + Function> ni, Function> fn) { return nearImage(NearImage.of(image, ni), fn); } + /** + * Aggregate results of a near image query. + * + * @param searchTarget Query target. + * @param fn Lambda expression for optional aggregation parameters. + * @return Aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * @see AggregateResponse + */ + public ResponseT nearImage(Target searchTarget, + Function> fn) { + return nearImage(NearImage.of(searchTarget), fn); + } + + /** + * Aggregate results of a near image query. + * + * @param searchTarget Query target. + * @param ni Lambda expression for optional near image parameters. + * @param fn Lambda expression for optional aggregation parameters. + * @return Aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * @see AggregateResponse + */ + public ResponseT nearImage(Target searchTarget, + Function> ni, + Function> fn) { + return nearImage(NearImage.of(searchTarget, ni), fn); + } + /** * Aggregate results of a near image query. * @@ -967,7 +1003,8 @@ public ResponseT nearImage(NearImage filter, Function> fn, + public GroupedResponseT nearImage(String image, + Function> fn, GroupBy groupBy) { return nearImage(NearImage.of(image), fn, groupBy); } @@ -987,11 +1024,55 @@ public GroupedResponseT nearImage(String image, Function> ni, - Function> fn, GroupBy groupBy) { + public GroupedResponseT nearImage(String image, + Function> ni, + Function> fn, + GroupBy groupBy) { return nearImage(NearImage.of(image, ni), fn, groupBy); } + /** + * Aggregate results of a near image query. + * + * @param searchTarget Query target. + * @param fn Lambda expression for optional aggregation parameters. + * @param groupBy GroupBy clause. + * @return Grouped aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * + * @see GroupBy + * @see AggregateResponseGrouped + */ + public GroupedResponseT nearImage(Target searchTarget, + Function> fn, + GroupBy groupBy) { + return nearImage(NearImage.of(searchTarget), fn, groupBy); + } + + /** + * Aggregate results of a near image query. + * + * @param searchTarget Query target. + * @param ni Lambda expression for optional near image parameters. + * @param fn Lambda expression for optional aggregation parameters. + * @param groupBy GroupBy clause. + * @return Grouped aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * + * @see GroupBy + * @see AggregateResponseGrouped + */ + public GroupedResponseT nearImage(Target searchTarget, + Function> ni, + Function> fn, + GroupBy groupBy) { + return nearImage(NearImage.of(searchTarget, ni), fn, groupBy); + } + /** * Aggregate results of a near image query. * @@ -1045,6 +1126,40 @@ public ResponseT nearAudio(String audio, Function> fn) { + return nearAudio(NearAudio.of(searchTarget), fn); + } + + /** + * Aggregate results of a near audio query. + * + * @param searchTarget Query target. + * @param na Lambda expression for optional near audio parameters. + * @param fn Lambda expression for optional aggregation parameters. + * @return Aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * @see AggregateResponse + */ + public ResponseT nearAudio(Target searchTarget, + Function> na, + Function> fn) { + return nearAudio(NearAudio.of(searchTarget, na), fn); + } + /** * Aggregate results of a near audio query. * @@ -1099,6 +1214,48 @@ public GroupedResponseT nearAudio(String audio, Function> fn, + GroupBy groupBy) { + return nearAudio(NearAudio.of(searchTarget), fn, groupBy); + } + + /** + * Aggregate results of a near audio query. + * + * @param searchTarget Query target. + * @param na Lambda expression for optional near audio parameters. + * @param fn Lambda expression for optional aggregation parameters. + * @param groupBy GroupBy clause. + * @return Grouped aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * + * @see GroupBy + * @see AggregateResponseGrouped + */ + public GroupedResponseT nearAudio(Target searchTarget, + Function> na, + Function> fn, + GroupBy groupBy) { + return nearAudio(NearAudio.of(searchTarget, na), fn, groupBy); + } + /** * Aggregate results of a near audio query. * @@ -1152,6 +1309,40 @@ public ResponseT nearVideo(String video, Function> fn) { + return nearVideo(NearVideo.of(searchTarget), fn); + } + + /** + * Aggregate results of a near video query. + * + * @param searchTarget Query target. + * @param nv Lambda expression for optional near video parameters. + * @param fn Lambda expression for optional aggregation parameters. + * @return Aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * @see AggregateResponse + */ + public ResponseT nearVideo(Target searchTarget, + Function> nv, + Function> fn) { + return nearVideo(NearVideo.of(searchTarget, nv), fn); + } + /** * Aggregate results of a near video query. * @@ -1206,6 +1397,48 @@ public GroupedResponseT nearVideo(String video, Function> fn, + GroupBy groupBy) { + return nearVideo(NearVideo.of(searchTarget), fn, groupBy); + } + + /** + * Aggregate results of a near video query. + * + * @param searchTarget Query target. + * @param nv Lambda expression for optional near video parameters. + * @param fn Lambda expression for optional aggregation parameters. + * @param groupBy GroupBy clause. + * @return Grouped aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * + * @see GroupBy + * @see AggregateResponseGrouped + */ + public GroupedResponseT nearVideo(Target searchTarget, + Function> nv, + Function> fn, + GroupBy groupBy) { + return nearVideo(NearVideo.of(searchTarget, nv), fn, groupBy); + } + /** * Aggregate results of a near video query. * @@ -1259,6 +1492,40 @@ public ResponseT nearThermal(String thermal, Function> fn) { + return nearThermal(NearThermal.of(searchTarget), fn); + } + + /** + * Aggregate results of a near thermal query. + * + * @param searchTarget Query target. + * @param nt Lambda expression for optional near thermal parameters. + * @param fn Lambda expression for optional aggregation parameters. + * @return Aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * @see AggregateResponse + */ + public ResponseT nearThermal(Target searchTarget, + Function> nt, + Function> fn) { + return nearThermal(NearThermal.of(searchTarget, nt), fn); + } + /** * Aggregate results of a near thermal query. * @@ -1313,6 +1580,48 @@ public GroupedResponseT nearThermal(String thermal, Function> fn, + GroupBy groupBy) { + return nearThermal(NearThermal.of(searchTarget), fn, groupBy); + } + + /** + * Aggregate results of a near thermal query. + * + * @param searchTarget Query target. + * @param nt Lambda expression for optional near thermal parameters. + * @param fn Lambda expression for optional aggregation parameters. + * @param groupBy GroupBy clause. + * @return Grouped aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * + * @see GroupBy + * @see AggregateResponseGrouped + */ + public GroupedResponseT nearThermal(Target searchTarget, + Function> nt, + Function> fn, + GroupBy groupBy) { + return nearThermal(NearThermal.of(searchTarget, nt), fn, groupBy); + } + /** * Aggregate results of a near thermal query. * @@ -1366,6 +1675,40 @@ public ResponseT nearDepth(String depth, Function> fn) { + return nearDepth(NearDepth.of(searchTarget), fn); + } + + /** + * Aggregate results of a near depth query. + * + * @param searchTarget Query target. + * @param nd Lambda expression for optional near depth parameters. + * @param fn Lambda expression for optional aggregation parameters. + * @return Aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * @see AggregateResponse + */ + public ResponseT nearDepth(Target searchTarget, + Function> nd, + Function> fn) { + return nearDepth(NearDepth.of(searchTarget, nd), fn); + } + /** * Aggregate results of a near depth query. * @@ -1420,6 +1763,48 @@ public GroupedResponseT nearDepth(String depth, Function> fn, + GroupBy groupBy) { + return nearDepth(NearDepth.of(searchTarget), fn, groupBy); + } + + /** + * Aggregate results of a near depth query. + * + * @param searchTarget Query target. + * @param nd Lambda expression for optional near depth parameters. + * @param fn Lambda expression for optional aggregation parameters. + * @param groupBy GroupBy clause. + * @return Grouped aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * + * @see GroupBy + * @see AggregateResponseGrouped + */ + public GroupedResponseT nearDepth(Target searchTarget, + Function> nd, + Function> fn, + GroupBy groupBy) { + return nearDepth(NearDepth.of(searchTarget, nd), fn, groupBy); + } + /** * Aggregate results of a near depth query. * @@ -1473,6 +1858,40 @@ public ResponseT nearImu(String imu, Function> fn) { + return nearImu(NearImu.of(searchTarget), fn); + } + + /** + * Aggregate results of a near IMU query. + * + * @param searchTarget Query target. + * @param ni Lambda expression for optional near IMU parameters. + * @param fn Lambda expression for optional aggregation parameters. + * @return Aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * @see AggregateResponse + */ + public ResponseT nearImu(Target searchTarget, + Function> ni, + Function> fn) { + return nearImu(NearImu.of(searchTarget, ni), fn); + } + /** * Aggregate results of a near IMU query. * @@ -1527,6 +1946,48 @@ public GroupedResponseT nearImu(String imu, Function> fn, + GroupBy groupBy) { + return nearImu(NearImu.of(searchTarget), fn, groupBy); + } + + /** + * Aggregate results of a near IMU query. + * + * @param searchTarget Query target. + * @param ni Lambda expression for optional near IMU parameters. + * @param fn Lambda expression for optional aggregation parameters. + * @param groupBy GroupBy clause. + * @return Grouped aggregation result. + * + * @throws WeaviateApiException in case the server returned with an + * error status code. + * + * @see GroupBy + * @see AggregateResponseGrouped + */ + public GroupedResponseT nearImu(Target searchTarget, + Function> ni, + Function> fn, + GroupBy groupBy) { + return nearImu(NearImu.of(searchTarget, ni), fn, groupBy); + } + /** * Aggregate results of a near IMU query. * From a6ac987dd486304fee2e2df38417da8e0596908e Mon Sep 17 00:00:00 2001 From: dyma solovei Date: Tue, 4 Nov 2025 16:32:39 +0100 Subject: [PATCH 15/15] chore: don't expose Metadata.VECTOR --- src/it/java/io/weaviate/integration/DataITest.java | 3 ++- .../v1/api/collections/query/BaseQueryOptions.java | 2 +- .../client6/v1/api/collections/query/ById.java | 2 +- .../client6/v1/api/collections/query/Metadata.java | 2 -- .../v1/api/collections/query/QueryReference.java | 13 ++++++++++++- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/it/java/io/weaviate/integration/DataITest.java b/src/it/java/io/weaviate/integration/DataITest.java index 4b29ee70e..27c3aafec 100644 --- a/src/it/java/io/weaviate/integration/DataITest.java +++ b/src/it/java/io/weaviate/integration/DataITest.java @@ -25,6 +25,7 @@ import io.weaviate.client6.v1.api.collections.data.DeleteManyResponse; import io.weaviate.client6.v1.api.collections.data.Reference; import io.weaviate.client6.v1.api.collections.query.Metadata; +import io.weaviate.client6.v1.api.collections.query.Metadata.MetadataField; import io.weaviate.client6.v1.api.collections.query.QueryMetadata; import io.weaviate.client6.v1.api.collections.query.QueryReference; import io.weaviate.client6.v1.api.collections.query.Where; @@ -54,7 +55,7 @@ public void testCreateGetDelete() throws IOException { var object = artists.query.byId(id, query -> query .returnProperties("name") .returnMetadata( - Metadata.VECTOR, + MetadataField.VECTOR, Metadata.CREATION_TIME_UNIX, Metadata.LAST_UPDATE_TIME_UNIX)); Assertions.assertThat(artists.data.exists(id)) diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/query/BaseQueryOptions.java b/src/main/java/io/weaviate/client6/v1/api/collections/query/BaseQueryOptions.java index dc145f690..382b9d48b 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/query/BaseQueryOptions.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/query/BaseQueryOptions.java @@ -172,7 +172,7 @@ public final SelfT returnMetadata(List metadata) { /** Include default vector. */ public final SelfT includeVector() { - return returnMetadata(Metadata.VECTOR); + return returnMetadata(MetadataField.VECTOR); } /** Include one or more named vectors in the metadata response. */ diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/query/ById.java b/src/main/java/io/weaviate/client6/v1/api/collections/query/ById.java index 86b39f9e7..babca7841 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/query/ById.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/query/ById.java @@ -86,7 +86,7 @@ public final Builder returnMetadata(List metadata) { /** Include default vector. */ public final Builder includeVector() { - return returnMetadata(Metadata.VECTOR); + return returnMetadata(MetadataField.VECTOR); } /** Include one or more named vectors in the metadata response. */ diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/query/Metadata.java b/src/main/java/io/weaviate/client6/v1/api/collections/query/Metadata.java index 3ec629c00..0c9e7bd4e 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/query/Metadata.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/query/Metadata.java @@ -13,8 +13,6 @@ public interface Metadata { /** Include metadata in the metadata response. */ public static final Metadata ALL = MetadataField.ALL; - /** Include associated vector in the metadata response. */ - public static final Metadata VECTOR = MetadataField.VECTOR; /** Include object creation time in the metadata response. */ public static final Metadata CREATION_TIME_UNIX = MetadataField.CREATION_TIME_UNIX; /** Include last update time in the metadata response. */ diff --git a/src/main/java/io/weaviate/client6/v1/api/collections/query/QueryReference.java b/src/main/java/io/weaviate/client6/v1/api/collections/query/QueryReference.java index c6aac5a77..fa6f9c7cb 100644 --- a/src/main/java/io/weaviate/client6/v1/api/collections/query/QueryReference.java +++ b/src/main/java/io/weaviate/client6/v1/api/collections/query/QueryReference.java @@ -128,7 +128,18 @@ public final Builder returnMetadata(List metadata) { /** Include the default vector of the referenced object. */ public final Builder includeVector() { - return returnMetadata(Metadata.VECTOR); + return returnMetadata(MetadataField.VECTOR); + } + + /** Include one or more named vectors in the metadata response. */ + public final Builder includeVector(String... vectors) { + return includeVector(Arrays.asList(vectors)); + } + + /** Include one or more named vectors in the metadata response. */ + public final Builder includeVector(List vectors) { + this.includeVectors.addAll(vectors); + return this; } @Override