Hybrid 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 searches for entities based on vector similarity and scalar filtering and reranks the results using a specified strategy.
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.
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 search parameters
Search parameter for a vector field.
A list of vector embeddings.Zilliz Cloud searches for the most similar vector embeddings to the specified ones.
A vector embedding
The name of the vector field.
A boolean expression filter.
The name of the field that serve as the aggregation criteria.
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.
The number of entities to return.
The number of entities to skip in the returned entities.
Whether to ignore the entities found in the growing segments.
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.
Expression template parameter values for parameterized filter expressions.
The reranking strategy.
The name of the reranking strategy.
A set of parameters related to the specified strategy
A tunable constant in the RRF algorithm. This applies only when the strategy is set to rrf.
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 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.
An array of fields to return along with the search results.
A field name
The consistency level of the search operation. The value should be the same as the consistency level of the target collection.
Function settings for the current search request.
The function definitions that functionScore applies when scoring the hybrid search results.
One function definition, identified by name and type, that reads the fields listed in inputFieldNames and writes its results to the fields listed in outputFieldNames.
The description of the function to apply.
A list of scalar fields to use as input for the function.
The name of one 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 one vector field that receives the output of 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.
Number of records to skip in the search results.
Name of the field to group search results by.
The function chains applied during search reranking.
One function chain applied during search reranking.
The name of the function to apply in the chain.
The ordered operations executed by the function chain.
A single operation in the ordered function chain.
An optional expression evaluated by this operation.
The ordered arguments passed to the expression.
A single argument in the ordered expression argument list.
The name of the column used as this argument. Exactly one of column and literal must be specified.
A literal value used as this argument. Exactly one of column and literal must be specified.
The name of the function to apply in this expression.
Extra parameters for the search, supplied as key-value pairs.
The input column names for the operation.
An input column name for the operation.
The name of the operation to perform in this function chain step.
The output column names produced by the operation.
The name of an output column produced by this operation in the function chain.
Extra search parameters for this operation, provided as key-value pairs.
The execution stage of the function chain. Supported value: FunctionChainStageL2Rerank.
export TOKEN="db_admin:xxxxxxxxxxxxx"
curl --request POST \
--url "${CLUSTER_ENDPOINT}/v2/vectordb/entities/hybrid_search" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Request-Timeout: 5" \
--header "Content-Type: application/json" \
-d '{
"collectionName": "test_collection",
"search": [
{
"data": [
[
0.673437956701697,
0.739243747672878
]
],
"annsField": "float_vector_1",
"limit": 10,
"outputFields": [
"*"
]
},
{
"data": [
[
0.075384179256879,
0.9971545645073111
]
],
"annsField": "float_vector_2",
"limit": 10,
"outputFields": [
"*"
]
}
],
"rerank": {
"strategy": "rrf",
"params": {
"k": 10
}
},
"limit": 3,
"outputFields": [
"user_id",
"word_count",
"book_describe"
]
}'
Returns the search results.
A response object returned by the hybrid search operation.
Response code.
Cost of this operation. This applies to free and serverless clusters only, indicating the vCU usage of the current request.
Search results
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.
The number of top-K results returned for each query vector.
The number of top-K results returned for a single 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.
Returns an error message.
Response code.
Error message.
{
"code": 0,
"cost": 0,
"data": [
{
"book_describe": "book_105",
"distance": 0.09090909,
"id": 450519760774180800,
"user_id": 5,
"word_count": 105
},
{
"book_describe": "book_246",
"distance": 0.09090909,
"id": 450519760774180900,
"user_id": 46,
"word_count": 246
},
{
"book_describe": "book_367",
"distance": 0.08333333600000001,
"id": 450519760774181060,
"user_id": 67,
"word_count": 367
}
]
}