milvus-logo
LFAI
< Docs
  • RESTful
    • Vector Operations

Search

Conducts a similarity search on the vector field in a collection.

POST
/v1/vector/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 scope should be limited to the specified partitions. If not specified, the search scope is the entire collection.

[]partitionNamesstring

partitionName

filterstring

The filter used to find matches for the search

limitinteger

The maximum number of entities to return. The sum of this value of that of offset should be less than 16,384.

Value Range: ≥ 1≤ 16384
offsetinteger

The number of entities to skip in the search results.
The sum of this value and that of limit should not be greater than 16,384.

Value Range: 0≤ 16384
outputFieldsarray

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

[]outputFieldsstring

An output field name.

vectorarrayrequired

The query vector in the form of a list of floating numbers. The length of the query vector should match the dimension of the vector field in the collection.

[]vectornumber<float32>

A floating number representing one of the dimensions of the vector to search for.

paramsobject

List of search parameters

radiusnumber<float64>

The angle where the vector with the least similarity resides.

range_filternumber<float64>required

Used in combination to filter vector field values whose similarity to the query vector falls into a specific range.

export TOKEN="root:Milvus"
curl --request POST \
--url "${CLUSTER_ENDPOINT}/v1/vector/search" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Content-Type: application/json" \
-d '{
"collectionName": "quick_setup",
"data": [
[
0.3580376395471989,
"Unknown type",
0.18414012509913835,
"Unknown type",
0.9029438446296592
]
],
"annsField": "vector",
"limit": 3,
"outputFields": [
"color"
]
}'
Responses200 - application/json
codeinteger

Response code.

dataarray

Response payload that carries the search results.

[]dataobject

Search results. By default, each entity object carries the id and distance fields. If outputFields is specified, the entity object also carries the specified fields.

idinteger

The ID of the entity.

distancenumber<float32>

The similarity score of the entity to the query vector.

Returns an error message.

codeinteger

Response code.

messagestring

Error message.

{
"code": 200,
"data": [
{
"color": "pink_8682",
"distance": 1,
"id": 0
},
{
"color": "red_7025",
"distance": 0.6290165,
"id": 1
},
{
"color": "red_4794",
"distance": 0.5975797,
"id": 4
}
]
}