Skip to main content

Query

Conducts a query on scalar fields in a collection.


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

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..

Query entities that meet specific conditions. For details on how to build filters, refer to Boolean Expression Rules.

curl --request POST \
--url "${CLUSTER_ENDPOINT}/v1/vector/query" \
--header "Authorization: Bearer ${TOKEN}" \
--header "accept: application/json" \
--header "content-type: application/json" \
-d '{
"collectionName": "medium_articles",
"outputFields": ["id", "title", "link"],
"filter": "id in [443300716234671427, 443300716234671426]",
"limit": 100,
"offset": 0
}'
Notes

When setting outputFields to count(\*), you need to set limit to 0 to get the total count of entities that meet the specified conditions.

Request

Parameters

  • No query parameters required

  • No path parameters required

Request Body

{
"dbName": "string",
"collectionName": "string",
"partitionNames": [],
"filter": "string",
"limit": "integer",
"offset": "integer",
"outputFields": []
}
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 and that of offset should be less than 16384.
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 be less than 16384.
The value is less than or equal to 16384.
outputFieldsarray
An array of fields to return along with the search results.
outputFields[]string

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.
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.
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.
90134No query content provided.
90139Type mismatch for field 'xxx'. expected type:xxx