Query()About to Deprecate
This method conducts metadata filtering within a collection.
func (c *GrpcClient) Query(ctx context.Context, collectionName string, partitionNames []string, expr string, outputFields []string, opts ...SearchQueryOptionFunc) (ResultSet, error)
Parameter  | Description  | Type  | 
|---|---|---|
  | Context for the current call to work.  | 
  | 
  | Name of a collection.  | 
  | 
  | List of partition names. If left empty, all partitions are involved in this operation. Otherwise, only the specified partitions are involved.  | 
  | 
  | Boolean expression for metadata filtering. For details, refer to Scalar Filtering Rules.  | 
  | 
  | List of field names to include in the return.  | 
  | 
  | Extra query options. You can add multiple   | 
  | 
Return
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
// query
queryRes, errQuery := mc.Query(context.Background(), collectionName, []string{}, "10< id < 20", []string{}, client.WithSearchQueryConsistencyLevel(entity.ClStrong))
if errQuery != nil {
   log.Fatal("failed to query collection:", errQuery.Error())
}
for _, res := range queryRes {
   log.Println(res.Name(), res.FieldData())
}