Get()
This method gets entities by their IDs.
func (c *GrpcClient) Get(ctx context.Context, collectionName string, ids entity.Column, opts ...GetOption) (ResultSet, error)
Parameter | Description | Type |
---|---|---|
| Context for the current call to work. |
|
| Name of a collection. |
|
| Boolean expression for metadata filtering. For details, refer to Scalar Filtering Rules. |
|
| Extra query options. You can add multiple |
|
client.GetOption
You can add extra settings to the Get()
request using the following methods.
Method | Description |
---|---|
| Sets the names of fields to be included in the return. |
| Restricts the query within the specified partitions. |
A client.ResultSet
, which is a slice of entity.Column
.
client.ResultSet
The client.ResultSet
provides the following methods for you to manipulate the query results.
Method | Return Type | Description |
---|---|---|
|
| Return the column with the provided name. |
|
| Return the number of entities in the query result. |
|
| Return a slice of the query result. |
Errors
Any error in the execution of the request. Possible errors are as follows:
-
ErrClientNotReady
: The client is not connected to Milvus. -
ErrCollectionNotExists
: The collection with the specified name does not exist. -
The call to this API fails.
Example
// get
ids := entity.NewColumnInt64("id", []int64{10, 11, 12, 19})
queryRes, errQuery := mc.Get(context.Background(), collectionName, ids, client.GetWithOutputFields("varchar"))
if errQuery != nil {
log.Fatal("failed to query collection:", errQuery.Error())
}
for _, res := range queryRes {
log.Println(res.Name(), res.FieldData())
}