milvus-logo
LFAI
< Docs
  • RESTful
    • Vector Operations

Search

Conducts a similarity search in a collection.

POST
https://${MILVUS_HOST}:${MILVUS_PORT}/v1/vector/search

Example

Search entities based on a given vector:

curl --request POST \
     --url "${MILVUS_HOST}:${MILVUS_PORT}/v1/vector/search" \
     --header "Authorization: Bearer ${TOKEN}" \
     --header "accept: application/json" \
     --header "content-type: application/json" \
     -d '{
        "collectionName": "medium_articles",
        "vector": [0.4882628, 0.85768371, 0.48556888, 0.9681036, 0.94807827, 0.80656861, 0.72123286, 0.81810534, 0.83713905, 0.73258409, 0.97732714, 0.09869599, 0.83189308, 0.33537219, 0.88647192, 0.66132137, 0.703723, 0.34379603, 0.74785059, 0.84559156, 0.65074354, 0.61864253, 0.73546132, 0.84872955, 0.6006182, 0.04830389, 0.37780669, 0.96101751, 0.22319285, 0.88504273, 0.44813016, 0.69746754, 0.5707871, 0.37386075, 0.25382573, 0.42397712, 0.89749552, 0.39729882, 0.38485115, 0.12583234, 0.47243267, 0.74576701, 0.45814588, 0.88024839, 0.72812605, 0.6622232, 0.31803479, 0.74101011, 0.76141925, 0.5024863, 0.47431501, 0.40002184, 0.45752955, 0.54383915, 0.67569667, 0.52164475, 0.33647519, 0.93068322, 0.65766685, 0.95959175, 0.83665213, 0.1753687, 0.27341319, 0.34550907, 0.79669369, 0.95065082, 0.30838918, 0.79784458, 0.37323557, 0.97728813, 0.11170225, 0.87876854, 0.85212036, 0.88599461, 0.76916602, 0.6094099, 0.4427332, 0.87373443, 0.18576099, 0.81970137, 0.74932009, 0.92106027, 0.76417889, 0.35671825, 0.09990157, 0.14570871, 0.43084067, 0.30551776, 0.63985873, 0.45777184, 0.16172334, 0.32226743, 0.27613814, 0.18182943, 0.7019827, 0.45446168, 0.31359211, 0.17426952, 0.19392872, 0.59816543, 0.31679765, 0.60059089, 0.92800561, 0.95165562, 0.55177484, 0.49510178, 0.60250447, 0.1519485, 0.33565446, 0.92865767, 0.86723503, 0.85392181, 0.85337828, 0.01631286, 0.25257909, 0.00124323, 0.59344951, 0.78468014, 0.61854741, 0.61980932, 0.87467147, 0.44361724, 0.97777631, 0.42543721, 0.5290862, 0.12384163, 0.45287003, 0.30333621, 0.10408064, 0.71930918, 0.90741917, 0.09838064, 0.66319033, 0.08133113, 0.30527365, 0.40877414, 0.11552966, 0.76451148, 0.00529968, 0.76741598, 0.90358724, 0.05710312, 0.32659557, 0.66143926, 0.3258203, 0.62721598, 0.18690116, 0.00184847, 0.11355109, 0.33962499, 0.64671448, 0.67297271, 0.02416349, 0.3173442, 0.54041374, 0.33752188, 0.75654937, 0.08236666, 0.40054276, 0.1021504, 0.20874325, 0.75615835, 0.54953906, 0.44659766, 0.16064502, 0.58682242, 0.15547067, 0.57503622, 0.07797247, 0.1559962, 0.94815864, 0.12474807, 0.0999395, 0.85504252, 0.55633022, 0.56959553, 0.75966109, 0.70444125, 0.66884798, 0.81692129, 0.06837097, 0.9714623, 0.86751075, 0.42125912, 0.44367403, 0.49978621, 0.32267559, 0.67220653, 0.56167557, 0.25248436, 0.94191099, 0.71508807, 0.64564731, 0.56824345, 0.29187781, 0.93961505, 0.28196959, 0.92713673, 0.7256734, 0.51042292, 0.81504509, 0.55849401, 0.19380059, 0.46767559, 0.52275063, 0.66075204, 0.97290358, 0.57524932, 0.7219121, 0.85188581, 0.26220385, 0.75686621, 0.51934907, 0.185452, 0.49708297, 0.95783663, 0.61397962, 0.45956795, 0.49311061, 0.49464425, 0.43094667, 0.76768303, 0.29252745, 0.57964633, 0.72950803, 0.94616381, 0.60436868, 0.47828997, 0.90345857, 0.92971537, 0.64784105, 0.18095567, 0.94852017, 0.05224637, 0.50829763, 0.89020778, 0.008269, 0.9500583, 0.20305412, 0.21179052, 0.28443536, 0.39540241, 0.20286982, 0.30968133, 0.2141927, 0.4390286, 0.12686093, 0.59583271, 0.88270185, 0.28187656, 0.90096987, 0.29104497, 0.38480562, 0.40069773, 0.52293091, 0.37621525]
      }'

Search entities and return specific fields:

curl --request POST \
     --url "${MILVUS_HOST}:${MILVUS_PORT}/v1/vector/search" \
     --header "Authorization: Bearer ${TOKEN}" \
     --header "accept: application/json" \
     --header "content-type: application/json" \
     -d '{
       "collectionName": "medium_articles",
       "outputFields": ["id", "title", "link", "distance"],
       "vector": [0.4882628, 0.85768371, 0.48556888, 0.9681036, 0.94807827, 0.80656861, 0.72123286, 0.81810534, 0.83713905, 0.73258409, 0.97732714, 0.09869599, 0.83189308, 0.33537219, 0.88647192, 0.66132137, 0.703723, 0.34379603, 0.74785059, 0.84559156, 0.65074354, 0.61864253, 0.73546132, 0.84872955, 0.6006182, 0.04830389, 0.37780669, 0.96101751, 0.22319285, 0.88504273, 0.44813016, 0.69746754, 0.5707871, 0.37386075, 0.25382573, 0.42397712, 0.89749552, 0.39729882, 0.38485115, 0.12583234, 0.47243267, 0.74576701, 0.45814588, 0.88024839, 0.72812605, 0.6622232, 0.31803479, 0.74101011, 0.76141925, 0.5024863, 0.47431501, 0.40002184, 0.45752955, 0.54383915, 0.67569667, 0.52164475, 0.33647519, 0.93068322, 0.65766685, 0.95959175, 0.83665213, 0.1753687, 0.27341319, 0.34550907, 0.79669369, 0.95065082, 0.30838918, 0.79784458, 0.37323557, 0.97728813, 0.11170225, 0.87876854, 0.85212036, 0.88599461, 0.76916602, 0.6094099, 0.4427332, 0.87373443, 0.18576099, 0.81970137, 0.74932009, 0.92106027, 0.76417889, 0.35671825, 0.09990157, 0.14570871, 0.43084067, 0.30551776, 0.63985873, 0.45777184, 0.16172334, 0.32226743, 0.27613814, 0.18182943, 0.7019827, 0.45446168, 0.31359211, 0.17426952, 0.19392872, 0.59816543, 0.31679765, 0.60059089, 0.92800561, 0.95165562, 0.55177484, 0.49510178, 0.60250447, 0.1519485, 0.33565446, 0.92865767, 0.86723503, 0.85392181, 0.85337828, 0.01631286, 0.25257909, 0.00124323, 0.59344951, 0.78468014, 0.61854741, 0.61980932, 0.87467147, 0.44361724, 0.97777631, 0.42543721, 0.5290862, 0.12384163, 0.45287003, 0.30333621, 0.10408064, 0.71930918, 0.90741917, 0.09838064, 0.66319033, 0.08133113, 0.30527365, 0.40877414, 0.11552966, 0.76451148, 0.00529968, 0.76741598, 0.90358724, 0.05710312, 0.32659557, 0.66143926, 0.3258203, 0.62721598, 0.18690116, 0.00184847, 0.11355109, 0.33962499, 0.64671448, 0.67297271, 0.02416349, 0.3173442, 0.54041374, 0.33752188, 0.75654937, 0.08236666, 0.40054276, 0.1021504, 0.20874325, 0.75615835, 0.54953906, 0.44659766, 0.16064502, 0.58682242, 0.15547067, 0.57503622, 0.07797247, 0.1559962, 0.94815864, 0.12474807, 0.0999395, 0.85504252, 0.55633022, 0.56959553, 0.75966109, 0.70444125, 0.66884798, 0.81692129, 0.06837097, 0.9714623, 0.86751075, 0.42125912, 0.44367403, 0.49978621, 0.32267559, 0.67220653, 0.56167557, 0.25248436, 0.94191099, 0.71508807, 0.64564731, 0.56824345, 0.29187781, 0.93961505, 0.28196959, 0.92713673, 0.7256734, 0.51042292, 0.81504509, 0.55849401, 0.19380059, 0.46767559, 0.52275063, 0.66075204, 0.97290358, 0.57524932, 0.7219121, 0.85188581, 0.26220385, 0.75686621, 0.51934907, 0.185452, 0.49708297, 0.95783663, 0.61397962, 0.45956795, 0.49311061, 0.49464425, 0.43094667, 0.76768303, 0.29252745, 0.57964633, 0.72950803, 0.94616381, 0.60436868, 0.47828997, 0.90345857, 0.92971537, 0.64784105, 0.18095567, 0.94852017, 0.05224637, 0.50829763, 0.89020778, 0.008269, 0.9500583, 0.20305412, 0.21179052, 0.28443536, 0.39540241, 0.20286982, 0.30968133, 0.2141927, 0.4390286, 0.12686093, 0.59583271, 0.88270185, 0.28187656, 0.90096987, 0.29104497, 0.38480562, 0.40069773, 0.52293091, 0.37621525],
       "filter": "id in [443300716234671427, 443300716234671426]",
       "limit": 100,
       "offset": 0
     }'

Request

Parameters

  • No query parameters required

  • No path parameters required

Request Body

{
    "collectionName": "string",
    "filter": "string",
    "limit": "integer",
    "offset": "integer",
    "outputFields": [],
    "vector": []
}
ParameterDescription
collectionNamestring(required)
The name of the collection to which this operation applies.
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 1024.
The value defaults to 100.
The value ranges from 1 to 100.
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 1024.
The maximum value is 1024.
outputFieldsarray
An array of fields to return along with the search results.
vectorarray (number [float32])(required)
The query vector in the form of a list of floating numbers.

Response

Returns the search results.

Response Bodies

  • Response body if we process your request successfully
{
    "code": 200,
    "data": {}
}
  • Response body if we failed to process your request
{
    "code": integer,
    "message": string
}

Properties

The properties in the returned response are listed in the following table.

PropertyDescription
codeinteger
Indicates whether the request succeeds.
  • 200: The request succeeds.
  • Others: Some error occurs.
dataarray
A data array of objects.
messagestring
Indicates the possible reason for the reported error.

Possible Errors

Error CodeDescription
800database not found
1800user hasn't authenticate
1801can only accept json format request
1802missing required parameters
1805fail to parse search result