跳到主要内容
版本:v2.5.x

Query()

This method performs a scalar-filtering query.

Go
func (c *Client) Query(ctx context.Context, option QueryOption, callOptions ...grpc.CallOption) (ResultSet, error)

Request Parameters​

Parameter

Description

Type

ctx

Context for the current call to work.

context.Context

option

Optional parameters of the methods.

QueryOption

callOptions

Optional parameters for calling the methods.

grpc.CallOption

QueryOption​

This is an interface type. The queryOption struct types implement this interface type.

You can use the NewQueryOption function to get the concrete implementation.

NewQueryOption​

The signature of this method is as follows:

Go
func NewQueryOption(collectionName string) *queryOption

Parameter

Description

Type

collectionName

Name of the target collection.

string

ResultSet​

This is a struct type. You can use the GetColumn method to get the result values in a specific field.

GetColumn​

This method returns the query result in a specific column. The signature is as follows:

Go
func (rs *ResultSet) GetColumn(fieldName string) column.Column

Parameter

Description

Type

fieldName

Name of the target field.

string

Return​

ResultSet

Example​

Text
rs, err := cli.Query(ctx, milvusclient.NewQueryOption("quick_setup").
WithFilter("emb_type == 3").
WithOutputFields("id", "emb_type"))
if err != nil {
// handle error
}

fmt.Println(rs.GetColumn("id"))