milvus-logo
LFAI
< Docs
  • RESTful
    • v2

Hybrid Search

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
Cluster Endpoint

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

http://localhost:19530

export CLUSTER_ENDPOINT="http://localhost:19530"
Parameters
Authorizationstringheaderrequired

The authentication token should be a pair of colon-joined username and password, like username:password.

Example Value: Bearer {{TOKEN}}
Request Bodyapplication/json
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.Milvus 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.

radiusinteger

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.

range_filterinteger

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.

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.

outputFieldsarray

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

[]outputFieldsstring

A field name

export TOKEN="root:Milvus"
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"
]
}'
Responses200 - application/json
codeinteger

Response code.

dataarray

Search results

[]dataobject

An entity object.

Returns an error message.

codeinteger

Response code.

messagestring

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
}
]
}