QueryCollectionData
Retrieving vector data.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
gpdb:QueryCollectionData |
create |
*Collection
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| DBInstanceId |
string |
No |
The ID of the instance. Note
You can call the DescribeDBInstances operation to query details for all AnalyticDB for PostgreSQL instances in a region, including their instance IDs. |
gp-xxxxxxxxx |
| Collection |
string |
Yes |
The name of the collection. Note
You can call the ListCollections operation to list available collections. |
document |
| Namespace |
string |
No |
The name of the namespace. Note
You can call the ListNamespaces operation to list available namespaces. |
mynamespace |
| NamespacePassword |
string |
Yes |
The password for the namespace. |
testpassword |
| Content |
string |
No |
The content for full-text search. If this parameter is omitted, only vector search is performed. If this parameter is specified, the system performs a hybrid search of vector search and full-text search. Note
You must specify one of the Content and Vector parameters. |
hello_world |
| Filter |
string |
No |
The filter conditions for data retrieval. It is in the format of a WHERE clause in SQL. This expression returns a boolean value, which can be a simple comparison operator, such as Note
|
pipeline_id='1yhpmo0rbn' AND (spu='10025667796135' AND dept_id='226') |
| TopK |
integer |
Yes |
Specifies the number of top results to return. |
10 |
| Vector |
array |
No |
The vector data. The length of the vector data must be the same as that specified in the CreateCollection operation. Note
|
|
|
number |
No |
The vector data. |
1.234 |
|
| SparseVector |
object |
No |
The sparse vector data. |
|
| Indices |
array |
No |
The array of indexes. Note
The number of elements in the array cannot exceed 4,000. |
|
|
integer |
No |
The index value. |
1 |
|
| Values |
array |
No |
The array of sparse vectors. |
|
|
number |
No |
The sparse vector data. |
1.2345 |
|
| RegionId |
string |
Yes |
The region ID of the instance. |
cn-hangzhou |
| Metrics |
string |
No |
The similarity algorithm for search. Valid values:
Note
If this parameter is not specified, the algorithm specified when the index is created is used. |
cosine |
| IncludeValues |
boolean |
No |
Specifies whether to return dense vector data. Valid values:
|
true |
| HybridSearch |
string |
No |
The hybrid search algorithm. If this parameter is empty, the system ranks results by directly comparing the scores from the vector search and the full-text search. Valid values:
|
RRF |
| HybridSearchArgs |
object |
No |
The parameters for the hybrid search algorithm. The following algorithms are supported: RRF and Weight.
|
|
|
object |
No |
The recall algorithm. |
||
|
any |
No |
The configurations of the recall algorithm. |
{ "RRF": { "k": 60 } } |
|
| OrderBy |
string |
No |
This parameter is left empty by default. It specifies the field based on which to sort the results. This parameter is not supported in hybrid search. The field must be a metadata field or a default field in the table, such as
|
chunk_id |
| Offset |
integer |
No |
This parameter is left empty by default. It specifies the start position of a paged query. This parameter is not supported in hybrid search. The value must be greater than or equal to 0. When this parameter is not empty, Total in the response indicates the total number of hits. This parameter is used with TopK. For example, if you want to retrieve chunks 0 to 44 with a page size of 20, you must send three requests:
|
0 |
| IncludeMetadataFields |
string |
No |
This parameter is left empty by default. It specifies the metadata fields to be returned. You can specify multiple fields and separate them with commas (,). |
title,content |
| WorkspaceId |
string |
No |
The ID of the workspace that consists of multiple database instances. You must specify this parameter or the DBInstanceId parameter. If both this parameter and DBInstanceId are specified, this parameter is used. |
gp-ws-***** |
| RelationalTableFilter |
object |
No |
Uses another relational table to filter vector data, which is similar to the JOIN operation. Note
The data of the relational table can be returned by setting the IncludeMetadataFields parameter. For example, |
|
| CollectionMetadataField |
string |
No |
The metadata field of the vector collection, which is used to associate with the fields of the vector table. |
doc_id |
| TableField |
string |
No |
The field of the relational table, which is 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 filter conditions for the relational table. |
tags @> ARRAY['art'] |
| IncludeSparseValues |
boolean |
No |
Specifies whether to return sparse vector data. Valid values:
|
false |
Response elements
|
Element |
Type |
Description |
Example |
|||||||||||||||||||||
|
object |
The recall results. |
|||||||||||||||||||||||
| Matches |
object |
|||||||||||||||||||||||
| match |
array<object> |
An array of matched items. |
||||||||||||||||||||||
|
array<object> |
A single matched record. |
|||||||||||||||||||||||
| Id |
string |
The unique ID of the vector data. |
doca-1234 |
|||||||||||||||||||||
| Metadata |
object |
The associated metadata. |
||||||||||||||||||||||
|
string |
The value of a metadata key. |
{"title":"test title", "content": "test content"} |
||||||||||||||||||||||
| Values |
object |
|||||||||||||||||||||||
| value |
array |
An array of floating-point numbers representing the dense vector. |
||||||||||||||||||||||
|
number |
A value within the dense vector. |
1.234 |
||||||||||||||||||||||
| Score |
number |
The similarity score of the data record. The score is based on the algorithm |
0.12345 |
|||||||||||||||||||||
| SparseValues |
object |
The sparse vector data. |
||||||||||||||||||||||
| Indices |
object |
|||||||||||||||||||||||
| Indice |
array |
An array of indices for the sparse vector. |
||||||||||||||||||||||
|
integer |
A single index value. |
20 |
||||||||||||||||||||||
| Values |
object |
|||||||||||||||||||||||
| Value |
array |
An array of values corresponding to the indices in the sparse vector. |
||||||||||||||||||||||
|
number |
A single value from the sparse vector. |
0.222 |
||||||||||||||||||||||
| MetadataV2 |
object |
The metadata. This field has the same values as Metadata, but uses a different element type to allow the SDK to deserialize values into their native data types. |
||||||||||||||||||||||
|
any |
The SDK deserializes this field's value according to the following rules. Note
Deserialization rules
|
{'array_field': [15.5, 25.5, 35.5], 'float_field': 128.45, 'long_field': 123456789017, 'bool_field': False, 'json_field': '{"key1":"value1","num":999.0}', 'char_array_field': '[c, h, a, r, s, 5]', 'int_field': 128, 'source': 0, 'double_field': 12350.6789, 'string_field': 'test_string_5'} |
||||||||||||||||||||||
| RequestId |
string |
The request ID. |
ABB39CC3-4488-4857-905D-2E4A051D0521 |
|||||||||||||||||||||
| Status |
string |
The status of the request. Valid values:
|
success |
|||||||||||||||||||||
| Message |
string |
Details about the error, returned if the request fails. |
0.1234 |
|||||||||||||||||||||
| Total |
integer |
The total number of hits for the search. This parameter is returned only when the Offset parameter in the request is not 0. |
100 |
Examples
Success response
JSON format
{
"Matches": {
"match": [
{
"Id": "doca-1234",
"Metadata": {
"key": "{\"title\":\"test title\", \"content\": \"test content\"}"
},
"Values": {
"value": [
1.234
]
},
"Score": 0.12345,
"SparseValues": {
"Indices": {
"Indice": [
20
]
},
"Values": {
"Value": [
0.222
]
}
},
"MetadataV2": {
"key": "{'array_field': [15.5, 25.5, 35.5], 'float_field': 128.45, 'long_field': 123456789017, 'bool_field': False, 'json_field': '{\"key1\":\"value1\",\"num\":999.0}', 'char_array_field': '[c, h, a, r, s, 5]', 'int_field': 128, 'source': 0, 'double_field': 12350.6789, 'string_field': 'test_string_5'}"
}
}
]
},
"RequestId": "ABB39CC3-4488-4857-905D-2E4A051D0521",
"Status": "success",
"Message": "0.1234",
"Total": 100
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.