Skip to main content

Search

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


POST
https://{cluster-endpoint}/v1/vector/search

Example

Notes

You can use either of the following ways to authorize:

  • An API Key with appropriate permissions.
  • A colon-joined username and password of the target cluster. For example, username:p@ssw0rd.

Currently, data of the JSON and Array types are not supported in RESTful API requests..

curl --request POST \
--url "${CLUSTER_ENDPOINT}/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 "${CLUSTER_ENDPOINT}/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

{
"dbName": "string",
"collectionName": "string",
"partitionNames": [],
"filter": "string",
"limit": "integer",
"offset": "integer",
"outputFields": [],
"vector": [],
"params": {
"radius": "number",
"range_filter": "number"
}
}
ParameterDescription
dbNamestring
The name of the database.
collectionNamestring
The name of the collection to which this operation applies.
partitionNamesarray
The name of the partitions to which this operation applies.
partitionNames[]string
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 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 value is less than or equal to 1024.
outputFieldsarray
An array of fields to return along with the search results.
outputFields[]string

The value defaults to id, distance
vectorarray
The query vector in the form of a list of floating numbers.
vector[]number (float32)
paramsobject
List of search parameters
params.radiusnumber (float64)
The angle where the vector with the least similarity resides.
params.range_filternumber (float64)
Used in combination to filter vector field values whose similarity to the query vector falls into a specific range.

Response

Returns the search results.

Response Bodies

  • Response body if we process your request successfully
{
"code": "integer",
"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
dataarray
data[]object
messagestring
Indicates the possible reason for the reported error.

Possible Errors

CodeError Message
80000Incorrect parameter: xxx
80001The token is illegal
80002The token is invalid
80020Cluster not exist or you don't have permission.
80022Dedicated cluster not support this operation.
90001The collection xxx does not exist. You can use ListCollections to view the list of existing collections.
90002The return value property xxx does not exist on collection xxx.
90004The parameter value for 'limit' should be between 1 and 100.
90005The parameter value for 'offset' should not be less than 0.
90006The attribute xxx is not of vector type
90007The vector dimensions do not match on the field xxx. The input vector has a dimension of xxx
90011Invalid CollectionName. Reason: Name contains only alphanumeric letters and underscores
90102The cluster does not exist in current region.
90103The clusterId parameter is empty in the request path.
90110No filter key field.
90111The parameter value for 'level' should be between 1 and 3.
90115The number of columns inserted does not match the defined number of columns in the set.
90125No vector key field.
90126The sum of the 'offset' parameter value and the 'limit' parameter value should not exceed 16384.
90135No search content provided.
90139Type mismatch for field 'xxx'. expected type:xxx