Search (V2)
orderByFields, groupByFields, searchAggregation) take effect only on clusters compatible with Milvus v3.0.x or later. On Zilliz Cloud, serverless clusters are compatible with Milvus v3.0.x, while Dedicated clusters are compatible with Milvus v2.6.x unless upgraded to the v3.0.x Public Preview.This operation conducts a vector similarity search with an optional scalar filtering expression.
The base URL for this API is in the following format:
https://{cluster-id}.{region}.vectordb.zillizcloud.com:19530
- Use the cluster endpoint if you are using serving clusters.
Free & Serverless
https://{cluster-id}.serverless.{region}.vectordb.zillizcloud.comDedicated
https://{cluster-id}.{region}.vectordb.zillizcloud.com:19530
- You need to fill in
${CLUSTER_ENDPOINT}with that of your Zilliz Cloud cluster. - To get the endpoint, use the Describe Cluster V2 API to extract the values from the responses.
export CLUSTER_ENDPOINT="https://{cluster-id}.{region}.vectordb.zillizcloud.com:19530"
The authentication token should be an API key with appropriate privileges or a pair of colon-joined username and password, like username:password. If you are using a project endpoint, only a valid API key with sufficient permissions applies.
The name of the database.
The name of the collection to which this operation applies.
A list of vector embeddings.
Zilliz Cloud searches for the most similar vector embeddings to the specified ones.
This parameter is mutually exclusive with ids.
A vector embedding
A list of primary keys.
Zilliz Cloud searches for the most similar vector embeddings to those in the specified entities.
This parameter is mutually exclusive with data.
The name of the vector field.
The filter used to find matches for the search.
Groups search results by a specified field to ensure diversity and avoid returning multiple results from the same group.
The number of entities to return for each group. This parameter is only valid when groupingField is specified.
Whether to return only the top k entities for each group. This parameter is only valid when groupingField is specified.
The total number of entities to return. You can use this parameter in combination with offset in param to enable pagination. The sum of this value and offset in param should be less than 16,384.
The number of records to skip in the search result. You can use this parameter in combination with limit to enable pagination. The sum of this value and limit should be less than 16,384.
An array of fields to return along with the search results.
A field name
The parameter settings specific to this operation.
The name of the metric type that applies to the current search. The value should be the same as the metric type of the target collection.
Extra search parameters.
Determines the threshold of least similarity. When setting metric_type to L2, ensure that this value is greater than that of range_filter. Otherwise, this value should be lower than that of range_filter.
Refines the search to vectors within a specific similarity range. When setting metric_type to IP or COSINE, ensure that this value is greater than that of radius. Otherwise, this value should be lower than that of radius.
The name of the partitions to which this operation applies. Setting this parameter indicates that the search is within the specified partitions. Otherwise, the search is across all partitions in the collection.
A partition name.
The consistency level of the search operation. The value should be the same as the consistency level of the target collection.
A set of key-value pairs that can be filled back in to the filter parameter to enable filtering templating. For details, refer to Filter Templating.
Function settings for the current search request.
The functions applied when function-based scoring is used in the search request, listed in an array.
A single function definition, identified by name and type and bound to its input and output fields through inputFieldNames and outputFieldNames.
The description of the function to apply.
A list of scalar fields to use as input for the function.
The name of a scalar field used as input to the function.
The name of the function to apply.
A list of vector fields to use as output for the function.
The name of a vector field used as output for the function.
Extra parameters for the function in key-value pairs.
The type of the function to apply.
Extra parameters for the function in key-value pairs.
Extra parameters for the search in key-value pairs.
Function chains applied during search reranking.
A function chain applied during search reranking.
The function-chain name.
The execution stage of the function chain.
The ordered operations in the function chain.
An operation in a function chain.
The operation name.
The optional expression evaluated by this operation.
The expression function name.
The ordered expression arguments.
An expression argument supplied as either a column or a literal.
A column name. Exactly one of column and literal must be specified.
A literal value. Exactly one of column and literal must be specified.
Expression parameters in key-value pairs.
Input column names.
An input column name.
Output column names.
An output column name.
Operation parameters in key-value pairs.
Aggregation settings for the search results. This parameter cannot be combined with ids, offset, or grouping parameters.
The non-empty scalar fields used to form aggregation buckets.
A scalar field used to form aggregation buckets.
The number of aggregation buckets to return.
The number of buckets considered during search. When specified, it must be greater than or equal to size.
Named metric aggregations keyed by result name.
Ordering rules for aggregation buckets.
An ordering rule for aggregation buckets.
The bucket count or metric key used for ordering.
The sort direction.
Top-hit settings for each aggregation bucket.
The number of top hits returned for each bucket.
Sort rules for top hits.
A sort rule for top hits.
The field used to sort top hits.
The sort direction.
A nested aggregation applied within each bucket. A search aggregation may nest at most 3 levels of sub-aggregations beneath the top-level aggregation (4 levels in total; deeper requests are rejected).
The non-empty scalar fields used to form aggregation buckets.
A scalar field used to form aggregation buckets.
The number of aggregation buckets to return.
The number of buckets considered during search. When specified, it must be greater than or equal to size.
Named metric aggregations keyed by result name.
Ordering rules for aggregation buckets.
An ordering rule for aggregation buckets.
The bucket count or metric key used for ordering.
The sort direction.
Top-hit settings for each aggregation bucket.
The number of top hits returned for each bucket.
Sort rules for top hits.
A sort rule for top hits.
The field used to sort top hits.
The sort direction.
A nested aggregation applied within each bucket. A search aggregation may nest at most 3 levels of sub-aggregations beneath the top-level aggregation (4 levels in total; deeper requests are rejected).
The scalar fields used to sort the search results. Each item can be a field name, fieldName:asc, or fieldName:desc; the default sort direction is ascending.
One sort specification for the search results, given as a field name (sorted ascending by default), fieldName:asc, or fieldName:desc.
export TOKEN="db_admin:xxxxxxxxxxxxx"
curl --request POST \
--url "${CLUSTER_ENDPOINT}/v2/vectordb/entities/search" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Request-Timeout: 5" \
--header "Content-Type: application/json" \
-d '{
"collectionName": "quick_setup",
"data": [
[
0.3580376395471989,
-0.6023495712049978,
0.18414012509913835,
-0.26286205330961354,
0.9029438446296592
]
],
"annsField": "vector",
"limit": 3,
"outputFields": [
"color"
],
"functionChains": [
{
"name": "l2",
"stage": "FunctionChainStageL2Rerank",
"ops": [
{
"op": "map",
"outputs": [
"new_score"
],
"expr": {
"name": "num_combine",
"args": [
{
"column": "$score"
},
{
"literal": 2.5
}
],
"params": {
"mode": "weighted"
}
}
}
]
}
],
"searchAggregation": {
"fields": [
"color"
],
"size": 10,
"order": [
{
"key": "_count",
"direction": "desc"
}
]
}
}'
Returns the search results.
One form of the successful response body, carrying the search results together with the topks and recalls arrays that describe each returned result group.
Response code.
Cost of this operation. This applies to free and serverless clusters only, indicating the vCU usage of the current request.
A list of entity objects.
An entity object.
The primary key value of the returned entity. Milvus primary keys are Int64 or VarChar depending on the collection schema, so the value may arrive as a number or a string.
The similarity distance between the query vector and this returned entity.
The group that this result belongs to, present when groupingField is specified.
Aggregated search buckets, present when searchAggregation is specified.
The number of entities aggregated into this bucket.
The search results aggregated into this bucket.
The key values that define this bucket.
The ID of the field that defines this bucket.
The name of the field that defines this bucket.
Aggregation metrics computed over the hits in this bucket.
The average distance of the hits in this bucket.
The maximum distance of the hits in this bucket.
The minimum distance of the hits in this bucket.
The number of hits aggregated into this bucket.
The total distance of the hits in this bucket.
Nested sub-groups of this bucket.
Recall values for each search result group.
The recall value for one search result group.
The number of top-K results returned for each query vector.
The number of top-K results returned for one query vector.
Returned when the deployment uses tiered storage with usage tracking enabled and the operation reads from remote/disk storage. Omitted when all data is served from local cache.
Returned when the deployment uses tiered storage with usage tracking enabled and the operation reads from remote/disk storage. Omitted when all data is served from local cache.
Returned when the deployment uses tiered storage with usage tracking enabled and the operation reads from remote/disk storage. Omitted when all data is served from local cache.
The top-k limits of the aggregated search branches, present when searchAggregation is specified.
Returns an error message.
Response code.
Error message.
{
"code": 0,
"data": [
{
"color": "orange_6781",
"distance": 1,
"id": 448300048035776800
},
{
"color": "red_4794",
"distance": 0.9353201,
"id": 448300048035776800
},
{
"color": "grey_8510",
"distance": 0.7733054,
"id": 448300048035776800
}
]
}