Search vectors
Connection and CORS help
Use HTTPS for remote clusters or HTTP on loopback. Requests go directly from your browser to the endpoint. Run List collections to populate the collection selector. When copying an authenticated cURL command, set MILVUS_TOKEN in your shell.
For cross-origin requests, configure the endpoint to answer OPTIONS and allow the docs origin, POST, Content-Type, and Authorization if you use a token. Try the copied cURL command to troubleshoot outside the browser.
POST/v2/vectordb/entities/search
{
"dbName": "default",
"collectionName": "books",
"data": [
[
0.1,
0.2,
0.3,
0.4
]
],
"annsField": "vector",
"limit": 5,
"outputFields": [
"title"
]
}Example response
{
"code": 0,
"data": [
{
"id": 101,
"title": "Invisible Cities",
"distance": 0.98
}
],
"cost": 0,
"topks": [
1
]
}cURL command
curl --request POST --url 'https://your-cluster.example.com/v2/vectordb/entities/search' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer ${MILVUS_TOKEN}" \
--data-raw '{
"dbName": "default",
"collectionName": "books",
"data": [
[
0.1,
0.2,
0.3,
0.4
]
],
"annsField": "vector",
"limit": 5,
"outputFields": [
"title"
]
}'Find nearest neighbors in a loaded collection. Provide query data or existing primary keys and select a vector field when needed.
You can apply a dense vector field from the described schema to fill a sample vector with the correct dimension. Replace the sample with your embedding before sending.
Request fields
dbNamestring- Database name. Operations on collections use default when omitted.
collectionNamestring (required)- Name of the collection.
dataarray of JSON value- Query inputs, such as an array of vectors. Supply data or ids.
idsarray of JSON value- Stored primary keys to search by, as an alternative to data.
annsFieldstring- Vector field to search. Specify it when the collection has multiple vector fields.
partitionNamesarray of string- Names of the partitions to target.
filterstring- Milvus scalar filter expression.
groupingFieldstring- Scalar field used to group search hits.
groupSizeinteger- Number of hits requested per group.
strictGroupSizeboolean- Require the specified number of hits in each result group.
limitinteger- Maximum number of rows or hits per query input.
offsetinteger- Number of matching results to skip.
outputFieldsarray of string- Field names to include in the returned entities.
searchParamsobject- Index-specific search parameters, including metric and search tuning options.
consistencyLevelstring- Read consistency level, such as Strong, Session, or Bounded.
exprParamsobject- Values for placeholders in a filter expression.
functionScoreobject- Scoring functions and parameters to apply to candidates.
functionChainsarray of object- Ordered function chains to apply during search.
searchAggregationobject- Bucket aggregation and metric configuration for search hits.
orderByFieldsarray of string- Field ordering expressions for sorted results.
paramsobject- Additional operation parameters.
See HttpClient.search for the Node.js SDK method.