< Docs
  • Java


A MilvusClient interface. This method gets entity(s) by their primary fields. Note that the order of the returned entities can not be guaranteed.

R<GetResponse> get(GetIdsParam requestParam);


Use the GetIdsParam.Builder to construct a GetIdsParam object.

import io.milvus.param.highlevel.dml.GetIdsParam;
GetIdsParam.Builder builder = GetIdsParam.newBuilder();

Methods of GetIdsParam.Builder:

withCollectionName(String collectionName)Sets the target collection name.
The value cannot be empty or null.
collectionName: Name of the collection from which entities are to be retrieved.
withPrimaryIds(List<T> primaryIds)Sets the IDs of the entities to retrieve.
The value cannot be empty or null.
primaryIds: A list of primary keys of the entities to retrieve.
addPrimaryId(T primaryId)Sets the ID of the entity you want to retrieve.
The value cannot be empty or null.
Use only the values of the primary key.
primaryId: ID of the entity you want to retrieve.
withOutputFields(List<String> outputFields)(Optional) Sets the output fields.outputFields: A list of output fields you prefer.
withConsistencyLevel(ConsistencyLevelEnum consistencyLevel)Sets the consistency level of the collection to get. If not specified, the default consistency level will be used. For details, refer to ConsistencyLevelEnum in Misc.consistencyLevel: The consistency level of the collection to get.
build()Constructs a GetIdsParam object.N/A

The method can throw the following exceptions:

  • ParamException is raised if the parameter is invalid.


This method catches all the exceptions and returns an R<GetResponse> object.

  • If the API fails on the server side, it returns the error code and message from the server.
  • If the API fails by RPC exception, it returns R.Status.Unknow and the error message of the exception.
  • If the API succeeds, it returns a valid GetResponse held by the R template.


import io.milvus.param.*;
import io.milvus.response.QueryResultsWrapper;
import io.milvus.response.FieldDataWrapper;
import io.milvus.grpc.QueryResults;

List<String> ids = Lists.newArrayList("441966745769900131", "441966745769900133");
GetIdsParam getParam = GetIdsParam.newBuilder()

R<GetResponse> response = client.get(param)
if (response.getStatus() != R.Status.Success.getCode()) {

for (QueryResultsWrapper.RowRecord rowRecord : response.getData().getRowRecords()) {