Retrieve 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 instance ID. Note
You can call the DescribeDBInstances operation to query the details of all AnalyticDB for PostgreSQL instances in a specific region, including instance IDs. |
gp-xxxxxxxxx |
| Collection |
string |
Yes |
The name of the collection. Note
You can call the ListCollections operation to query a list of collections. |
document |
| Namespace |
string |
No |
The namespace. Note
You can call the ListNamespaces operation to query a list of namespaces. |
mynamespace |
| NamespacePassword |
string |
Yes |
The password for the namespace. |
testpassword |
| Content |
string |
No |
The content for full-text search. If you specify this parameter, a hybrid search is performed. If this parameter is empty, only a vector search is performed. Note
You cannot leave both this parameter and the |
hello_world |
| Filter |
string |
No |
The filter condition for the query, specified in the format of a SQL WHERE clause. The expression must return a boolean value ( Note
|
pipeline_id='1yhpmo0rbn' AND (spu='10025667796135' AND dept_id='226') |
| TopK |
integer |
Yes |
The number of top results to return. |
10 |
| Vector |
array |
No |
The dense vector for the query. The number of dimensions must match the dimension specified when you call the CreateCollection API. Note
|
|
|
number |
No |
An element in the vector array. |
1.234 |
|
| SparseVector |
object |
No |
The sparse vector for the query. |
|
| Indices |
array |
No |
The array of indices for the non-zero elements in the sparse vector. Note
The number of elements in the array cannot exceed 4,000. |
|
|
integer |
No |
An index. |
1 |
|
| Values |
array |
No |
The array of values that corresponds to the indices. |
|
|
number |
No |
A value. |
1.2345 |
|
| RegionId |
string |
Yes |
The region ID of the instance. |
cn-hangzhou |
| Metrics |
string |
No |
The similarity metric for the search. Valid values:
Note
If you do not specify this parameter, the system uses the metric specified during index creation. |
cosine |
| IncludeValues |
boolean |
No |
Specifies whether to return vector data in the query results. Valid values:
|
true |
| HybridSearch |
string |
No |
The hybrid search algorithm. If you do not specify this parameter, the system directly compares and sorts the scores from the vector search and full-text search. Valid values:
|
RRF |
| HybridSearchArgs |
object |
No |
The parameters for the specified hybrid search algorithm. The following algorithms are supported:
|
|
|
object |
No |
|||
|
any |
No |
{ "Weight": { "alpha": 0.5 } } |
||
| OrderBy |
string |
No |
The field used for sorting. This parameter is not supported in hybrid search scenarios. By default, this parameter is empty. The field must be a metadata field or a default field in the table, such as
|
chunk_id |
| Offset |
integer |
No |
The starting point for a paginated query. By default, this parameter is empty. This parameter is not supported in hybrid search scenarios. The value must be greater than or equal to 0. When you specify this parameter, the response includes a
|
0 |
| IncludeMetadataFields |
string |
No |
The metadata fields to return. By default, this parameter is empty. To return multiple fields, separate them with commas. |
title,content |
| WorkspaceId |
string |
No |
The ID of the workspace, which consists of multiple database instances. You cannot leave both this parameter and the |
gp-ws-***** |
| RelationalTableFilter |
object |
No |
Filters Vector Search results by joining with a relational table. Note
To return data from the relational table, specify the fields in the |
|
| CollectionMetadataField |
string |
No |
The metadata field in the vector collection that joins with a field in the relational table. |
doc_id |
| TableField |
string |
No |
The field in the relational table that joins with the metadata field in the vector collection. |
id |
| TableName |
string |
No |
The name of the relational table. |
my_rds_table |
| Condition |
string |
No |
The filter condition for the relational table. |
tags @> ARRAY['art'] |
| IncludeSparseValues |
boolean |
No |
Specifies whether to return sparse vector data in the query results. Valid values:
|
Response elements
|
Element |
Type |
Description |
Example |
|||||||||||||||||||||
|
object |
The query response object. |
|||||||||||||||||||||||
| Matches |
object |
The matched results. |
||||||||||||||||||||||
| match |
array<object> |
A list of matches. |
||||||||||||||||||||||
|
array<object> |
A single Record. |
|||||||||||||||||||||||
| Id |
string |
The unique ID of the vector data. |
doca-1234 |
|||||||||||||||||||||
| Metadata |
object |
The Metadata associated with the Record. |
||||||||||||||||||||||
|
string |
The metadata content. |
{"title":"test title", "content": "test content"} |
||||||||||||||||||||||
| Values |
object |
The Vector Data. |
||||||||||||||||||||||
| value |
array |
An array of numbers that represents the vector. |
||||||||||||||||||||||
|
number |
A single value from the vector. |
1.234 |
||||||||||||||||||||||
| Score |
number |
The Similarity Score for this record. The score is calculated based on the metric ( |
0.12345 |
|||||||||||||||||||||
| SparseValues |
object |
The sparse vector data. |
||||||||||||||||||||||
| Indices |
object |
The indices of the sparse vector. |
||||||||||||||||||||||
| Indice |
array |
An array of indices for the sparse vector. |
||||||||||||||||||||||
|
integer |
A single index from the sparse vector. |
|||||||||||||||||||||||
| Values |
object |
The values of the sparse vector. |
||||||||||||||||||||||
| Value |
array |
An array of values for the sparse vector. |
||||||||||||||||||||||
|
number |
A single value from the sparse vector. |
|||||||||||||||||||||||
| MetadataV2 |
object |
The metadata. This field has the same values as the |
||||||||||||||||||||||
|
any |
This field can contain various data types. The SDK deserializes the data based on 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 request. This field is returned only if the request fails. |
0.1234 |
|||||||||||||||||||||
| Total |
integer |
The total number of hits that match the search criteria. This field is returned only if the |
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": [
0
]
},
"Values": {
"Value": [
0
]
}
},
"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.