Hybrid Search
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_ENDPOINT}
- You need to fill in
${CLUSTER_ENDPOINT}
with that of your Zilliz Cloud cluster. - To get the endpoint, refer to On Zilliz Cloud Console or use the Describe Cluster V2 API to extract the values from the responses.
export CLUSTER_ENDPOINT=""
The authentication token should be an API key with appropriate privileges or a pair of colon-joined username and password, like username:password
.
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 metrictype to L2, ensure that this value is greater than that of rangefilter. 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 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.
An array of fields to return along with the search results.
A field name
export TOKEN="db_admin:xxxxxxxxxxxxx"
curl --request POST \
--url "${CLUSTER_ENDPOINT}/v2/vectordb/entities/hybrid_search" \
--header "Authorization: Bearer ${TOKEN}" \
--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"
]
}'
Response code.
Search results
An entity object.
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
}
]
}