Query Vector Data
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- For mandatory resource types, indicate with a prefix of * .
- If the permissions cannot be granted at the resource level,
All Resourcesis used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
| Operation | Access level | Resource type | Condition key | Associated operation |
|---|---|---|---|---|
| gpdb:QueryCollectionData | create | *Collection acs:gpdb:{#regionId}:{#accountId}:collection/{#DBInstanceId} |
| none |
Request parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| DBInstanceId | string | No | Instance ID. Note
You can call the DescribeDBInstances API to view details of all AnalyticDB PostgreSQL instances in the target region, including the instance ID.
| gp-xxxxxxxxx |
| Collection | string | Yes | Collection name. Note
You can use the ListCollections API to view the list.
| document |
| Namespace | string | No | Namespace. Note
You can use the ListNamespaces API to view the list.
| mynamespace |
| NamespacePassword | string | Yes | Password for the namespace. | testpassword |
| Content | string | No | Content for full-text search. When this value is empty, only vector search is used; when it is not empty, both vector and full-text search are used. Note
The Vector parameter cannot be empty at the same time.
| hello_world |
| Filter | string | No | Filter conditions for the data to be queried, in SQL WHERE format. It is an expression that returns a boolean value (true or false). Conditions can be simple comparison operators such as equal (=), not equal (<> or !=), greater than (>), less than (<), greater than or equal to (>=), less than or equal to (<=), or more complex expressions combined with logical operators (AND, OR, NOT), as well as conditions using keywords like IN, BETWEEN, and LIKE. Note
| response > 200 |
| TopK | long | Yes | Set the number of top results to return. | 10 |
| Vector | array | No | Vector data, with the same dimension as specified in the CreateCollection API. Note
When the vector is empty, only full-text search results are returned.
| |
| double | No | Vector data. | 1.234 | |
| RegionId | string | Yes | Region ID where the instance is located. | cn-hangzhou |
| Metrics | string | No | Similarity algorithm used during retrieval. Value descriptions:
Note
If this value is empty, the algorithm specified during index creation is used.
| cosine |
| IncludeValues | boolean | No | Whether to return vector data. Value descriptions:
| true |
| HybridSearch | string | No | Dual-path recall algorithm, default is empty (i.e., directly compare and sort the scores of vectors and full-text). Available values:
| RRF |
| HybridSearchArgs | object | No | The parameters of the two-way retrieval algorithm. The following parameters are supported:
| |
| object | No | The two-way retrieval parameters. | ||
| any | No | The parameter values. | { "Weight": { "alpha": 0.5 } } | |
| OrderBy | string | No | Defaults to empty, indicating the field for sorting. Does not support hybrid search scenarios. The field must belong to metadata or be a default field in the table, such as
| chunk_id |
| Offset | integer | No | Defaults to empty, indicating the starting point for pagination queries. Does not support hybrid search scenarios. The value must be >= 0. When this value is not empty, it will return
| 0 |
| IncludeMetadataFields | string | No | Defaults to empty, indicating the metadata fields to return. Multiple fields should be separated by commas. | title,content |
| WorkspaceId | string | No | The ID of the Workspace composed of multiple database instances. This parameter and | gp-ws-***** |
| RelationalTableFilter | object | No | Uses another relational table to filter vector data (similar to a Join function). Note
Data from the relational table can be returned by setting the IncludeMetadataFields parameter. For example, rds_table_name.id indicates returning the id field from the relational table.
| |
| CollectionMetadataField | string | No | The Metadata field of the vector collection, used to associate with the fields in the vector table. | doc_id |
| TableField | string | No | The field in the relational table, used to associate with the Metadata field of the vector collection. | id |
| TableName | string | No | The name of the relational table. | my_rds_table |
| Condition | string | No | The filtering condition for the relational table. | tags @> ARRAY['art'] |
Response parameters
Examples
Sample success responses
JSONformat
{
"Matches": {
"match": [
{
"Id": "doca-1234",
"Metadata": {
"key": {
"title": "test title",
"content": "test content"
}
},
"Values": {
"value": [
1.234
]
},
"Score": 0.12345
}
]
},
"RequestId": "ABB39CC3-4488-4857-905D-2E4A051D0521",
"Status": "success",
"Message": 0.1234,
"Total": 100
}Error codes
For a list of error codes, visit the Service error codes.
Change history
| Change time | Summary of changes | Operation |
|---|---|---|
| 2024-08-28 | The request parameters of the API has changed | View Change Details |
| 2024-08-04 | The request parameters of the API has changed | View Change Details |
| 2024-04-29 | The request parameters of the API has changed. The response structure of the API has changed | View Change Details |
| 2024-04-22 | The request parameters of the API has changed | View Change Details |
| 2023-11-07 | The internal configuration of the API is changed, but the call is not affected | View Change Details |
| 2023-08-17 | The request parameters of the API has changed | View Change Details |
| 2023-08-08 | The response structure of the API has changed | View Change Details |
| 2023-08-01 | The response structure of the API has changed | View Change Details |
| 2023-08-01 | The internal configuration of the API is changed, but the call is not affected | View Change Details |
