milvus-logo
LFAI
< Docs
  • Java

queryAsync()

A MilvusClient interface. This method queries entity(s) asynchronously based on scalar field(s) filtered by boolean expression.

The order of the returned entities cannot be guaranteed.
ListenableFuture<R<QueryResults>> queryAsync(QueryParam requestParam);

This method uses the same parameter as <a href="query().md"query(). It invokes RPC interface and returns a ListenableFuture object immediately.

Example

import io.milvus.param.*;
import io.milvus.grpc.QueryResults;
import com.google.common.util.concurrent.ListenableFuture;

QueryParam param = QueryParam.newBuilder()
        .withCollectionName("collection1")
        .withExpr("id in [100, 101]")
        .addOutFields("field1")
        .withConsistencyLevel(ConsistencyLevelEnum.EVENTUALLY)
        .build();
ListenableFuture<R<QueryResults>> futureResults = client.queryAsync(param);
R<QueryResults> response = futureResults.get();
if (response.getStatus() != R.Status.Success.getCode()) {
    System.out.println(response.getMessage());
}