Skip to main content

Hybrid Search (V2)

Milvus version compatibility
Server-side sorting, grouping, and search aggregation parameters (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.

POST/v2/vectordb/entities/hybrid_search
Connection Endpoint

The base URL for this API is in the following format:

https://{cluster-id}.{region}.vectordb.zillizcloud.com:19530

📘Notes
  • Use the cluster endpoint if you are using serving clusters.
    • Free & Serverless

      https://{cluster-id}.serverless.{region}.vectordb.zillizcloud.com

    • Dedicated

      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.
shell
export CLUSTER_ENDPOINT="https://{cluster-id}.{region}.vectordb.zillizcloud.com:19530"
Parameters
Authorizationstringheaderrequired

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.

Example Value: Bearer {{TOKEN}}
Request Body
dbNamestring

The name of the database.

collectionNamestringrequired

The name of the collection to which this operation applies.

partitionNamesarray

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.

[]partitionNamesstring

A partition name.

searcharrayrequired

The search parameters

[]searchobjectrequired

Search parameter for a vector field.

dataarrayrequired

A list of vector embeddings.Zilliz Cloud searches for the most similar vector embeddings to the specified ones.

[]datanumber<float32>

A vector embedding

annsFieldstringrequired

The name of the vector field.

filterstringrequired

A boolean expression filter.

groupingFieldstringrequired

The name of the field that serve as the aggregation criteria.

metricTypestring

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.

limitintegerrequired

The number of entities to return.

offsetintegerrequired

The number of entities to skip in the returned entities.

ignoreGrowingbooleanrequired

Whether to ignore the entities found in the growing segments.

paramsobject

Extra search parameters.

radiusnumber<float64>

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.

range_filternumber<float64>

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.

exprParamsobject

Expression template parameter values for parameterized filter expressions.

rerankobject

The reranking strategy.

strategystring

The name of the reranking strategy.

paramsobjectrequired

A set of parameters related to the specified strategy

kintegerrequired

A tunable constant in the RRF algorithm. This applies only when the strategy is set to rrf.

limitinteger

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.

groupSizeinteger

The number of entities to return for each group. This parameter is only valid when groupingField is specified.

strictGroupSizeboolean

Whether to return only the top k entities for each group. This parameter is only valid when groupingField is specified.

outputFieldsarray

An array of fields to return along with the search results.

[]outputFieldsstring

A field name

consistencyLevelstring

The consistency level of the search operation. The value should be the same as the consistency level of the target collection.

functionScoreobject

Function settings for the current search request.

functionsarray

The function definitions that functionScore applies when scoring the hybrid search results.

[]functionsobject

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.

descriptionstring

The description of the function to apply.

inputFieldNamesarrayrequired

A list of scalar fields to use as input for the function.

[]inputFieldNamesstring

The name of one scalar field used as input to the function.

namestringrequired

The name of the function to apply.

outputFieldNamesarrayrequired

A list of vector fields to use as output for the function.

[]outputFieldNamesstring

The name of one vector field that receives the output of the function.

paramsobject

Extra parameters for the function in key-value pairs.

typestringrequired

The type of the function to apply.

paramsobject

Extra parameters for the function in key-value pairs.

offsetinteger

Number of records to skip in the search results.

groupingFieldstring

Name of the field to group search results by.

functionChainsarray

The function chains applied during search reranking.

[]functionChainsobject

One function chain applied during search reranking.

namestringPublic Preview

The name of the function to apply in the chain.

opsarray

The ordered operations executed by the function chain.

[]opsobject

A single operation in the ordered function chain.

exprobject

An optional expression evaluated by this operation.

argsarray

The ordered arguments passed to the expression.

[]argsobject

A single argument in the ordered expression argument list.

columnstringPublic Preview

The name of the column used as this argument. Exactly one of column and literal must be specified.

literalundefinedPublic Preview

A literal value used as this argument. Exactly one of column and literal must be specified.

namestringPublic Preview

The name of the function to apply in this expression.

paramsobject

Extra parameters for the search, supplied as key-value pairs.

inputsarray

The input column names for the operation.

[]inputsstringPublic Preview

An input column name for the operation.

opstringPublic Preview

The name of the operation to perform in this function chain step.

outputsarray

The output column names produced by the operation.

[]outputsstringPublic Preview

The name of an output column produced by this operation in the function chain.

paramsobject

Extra search parameters for this operation, provided as key-value pairs.

stagestringPublic Preview

The execution stage of the function chain. Supported value: FunctionChainStageL2Rerank.

bash
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"
]
}'
Responses

Returns the search results.

A response object returned by the hybrid search operation.

codeinteger

Response code.

costinteger

Cost of this operation. This applies to free and serverless clusters only, indicating the vCU usage of the current request.

dataarray

Search results

[]dataobject

An entity object.

idoneOf

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.

integer
(To be added soon)
string
(To be added soon)
distancenumber

The similarity distance between the query vector and this returned entity.

grpstring

The group that this result belongs to, present when groupingField is specified.

topksarray

The number of top-K results returned for each query vector.

[]topksinteger

The number of top-K results returned for a single query vector.

scanned_remote_bytesinteger

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.

scanned_total_bytesinteger

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.

cache_hit_rationumber

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.

codeinteger

Response code.

messagestring

Error message.

Successjson
{
"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
}
]
}