Retrieve vectors and metadata from multiple specified knowledge bases using natural-language queries. Merge results from multi-channel recall and return them.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
gpdb:QueryKnowledgeBasesContent |
create |
*Document
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| DBInstanceId |
string |
Yes |
The ID of the instance. Note
Call the DescribeDBInstances operation to view details of all AnalyticDB for PostgreSQL instances in the destination region, including their instance IDs. |
gp-xxxxxxxxx |
| RegionId |
string |
Yes |
The ID of the region where the instance resides. |
cn-beijing |
| Content |
string |
Yes |
The text content to search for. |
ADBPG是什么? |
| MergeMethod |
string |
No |
The method used to merge results from multiple knowledge bases. Default value: RRF. Valid values:
|
RRF |
| MergeMethodArgs |
object |
No |
The parameters for the merge method of each SourceCollection. |
|
| Rrf |
object |
No |
The parameters you can configure when MergeMethod is set to RRF. |
|
| K |
integer |
No |
The constant k in the scoring formula 1/(k+rank_i). It must be a positive integer greater than 1. |
60 |
| Weight |
object |
No |
The parameters you can configure when MergeMethod is set to Weight. |
|
| Weights |
array |
No |
The array of weights for each SourceCollection. |
|
|
number |
No |
The weight for each SourceCollection. |
0.5 |
|
| RerankFactor |
number |
No |
The reranking factor. If this value is not empty, the vector retrieval results are reranked. Valid values: 1 < RerankFactor ≤ 5. Note
|
2 |
| SourceCollection |
array<object> |
Yes |
The information about multiple collections to search. |
|
|
array<object> |
No |
Knowledge base |
||
| Collection |
string |
Yes |
The name of the document collection. Note
Create a collection by calling the CreateDocumentCollection operation. Call the ListDocumentCollections operation to view existing collections. |
knowledge22 |
| Namespace |
string |
No |
The namespace. Note
Create a namespace by calling the CreateNamespace operation. Call the ListNamespaces operation to view the list. |
ns_cloud_index |
| NamespacePassword |
string |
Yes |
The password for the namespace. Note
This value is specified in the CreateNamespace operation. |
ns_password |
| QueryParams |
object |
No |
The filter condition for the data to retrieve, formatted as a SQL WHERE clause. |
|
| Filter |
string |
No |
The filter condition for the data to retrieve, formatted as a SQL WHERE clause. This is a Boolean expression that evaluates to true or false. Conditions can use simple comparison operators such as equals (=), not equals (<> or !=), greater than (>), less than (<), greater than or equal to (>=), or less than or equal to (<=). They can also use logical operators (AND, OR, NOT) to combine more complex expressions, or keywords such as IN, BETWEEN, and LIKE. Note
|
id = 'llm-52tvykqt6u67iw73_j6ovptwjk7_file_6ce3da1f7e69495d9f491f2180c86973_11967297' |
| GraphEnhance |
boolean |
No |
Whether to enable knowledge graph enhancement. Default value: false. |
true |
| GraphSearchArgs |
object |
No |
The number of top entities and relationship edges to return. Default value: 60. |
|
| GraphTopK |
integer |
No |
The number of top entities and relationship edges to return. Default value: 60. |
60 |
| HybridSearch |
string |
No |
The hybrid search algorithm. Default value: empty (the scores from dense vectors and full-text search are compared and sorted directly). Valid values:
|
Cascaded |
| HybridSearchArgs |
object |
No |
The parameters for the hybrid search algorithm. Currently supports RRF and Weight. HybridPathsSetting specifies which retrieval paths to use: dense vectors (dense), sparse vectors (sparse), and full-text search (fulltext). If empty, the default paths are dense vectors and full-text search.
|
|
|
any |
No |
The parameter configuration value. |
{ "RRF": { "k": 60 } } |
|
| Metrics |
string |
No |
The metric used when building the vector index. Valid values:
|
cosine |
| RecallWindow |
array |
No |
The recall window. If this value is not empty, it adds context to the returned search results. Format: a two-element array List<A, B>, where −10 ≤ A ≤ 0 and 0 ≤ B ≤ 10. Note
|
|
|
integer |
No |
The recall window range value. |
[0,0] |
|
| RerankFactor |
number |
No |
The reranking factor. If this value is not empty, the vector retrieval results are reranked. Valid values: 1 < RerankFactor ≤ 5. Note
|
2.0 |
| TopK |
integer |
No |
The number of top results to return. |
776 |
| UseFullTextRetrieval |
boolean |
No |
Whether to use full-text retrieval (two-path retrieval). Default value: false. Only vector retrieval is used if this value is false. |
false |
| OrderBy |
string |
No |
This parameter specifies the field for sorting and is empty by default. The field must be part of the metadata or a default field in the table, such as `id`. The format supports the following options: You can specify a single field, such as `chunk_id`. You can also specify multiple fields separated by commas, such as `block_id, chunk_id`. Descending order is also supported. For example: `block_id DESC, chunk_id DESC`. |
file_id,sort_num |
| Offset |
integer |
No |
The offset for paged queries. |
20 |
| TopK |
integer |
No |
The number of top results to return after merging multi-channel recall results. |
10 |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The request ID. |
ABB39CC3-4488-4857-905D-2E4A051D0521 |
| Message |
string |
The response message. |
success |
| Status |
string |
The status of the API call. Valid values:
|
success |
| Matches |
object |
||
| MatchList |
array<object> |
A single record. |
|
|
array<object> |
A single record. |
||
| Id |
string |
The unique ID of the vector data. |
doca-1234 |
| Content |
string |
The text content. |
云原生数据仓库AnalyticDB PostgreSQL版提供简单、快速、经济高效的PB级云端数据仓库解决方案。 |
| Metadata |
object |
The metadata map. |
|
|
string |
The value of the metadata map. |
{\"pic_id\":\"text\",\"pic_name\":\"text\",\"pic_url\":\"text\"} |
|
| FileName |
string |
The file name. |
my_doc.txt |
| Score |
number |
The similarity score for this item. The scoring algorithm matches the one specified when creating the index (l2, ip, or cosine). |
0.12345 |
| RetrievalSource |
integer |
The source of the retrieval result. Possible values are: 1 for vector retrieval, 2 for full-text index, and 3 for dual-path retrieval. |
1 |
| LoaderMetadata |
string |
The metadata added by the document loader. |
{"page_pos": 1} |
| FileURL |
string |
The public URL of the image in the query result. Default validity period: 2 hours. You can specify a custom validity period using the UrlExpiration request parameter. |
https://xxx-cn-beijing.aliyuncs.com/image/test.png |
| RerankScore |
number |
The reranking score. |
6.2345 |
| EmbeddingTokens |
string |
The number of tokens used during vectorization. Note
A token is the smallest unit into which input text is divided. A token can be a word, phrase, punctuation mark, or character. |
100 |
| Usage |
object |
The resource usage for this query. |
|
| EmbeddingTokens |
string |
The number of tokens used during vectorization. Note
A token is the smallest unit into which input text is divided. A token can be a word, phrase, punctuation mark, or character. |
475 |
| EmbeddingEntries |
string |
The number of entries processed during vectorization. Note
An entry is a processing unit for text or images. For example, processing one piece of text counts as one entry. Processing one image counts as two entries. |
10 |
| Entities |
object |
||
| entities |
array<object> |
Details about the entity. |
|
|
object |
Details about the entity. |
||
| Id |
string |
The ID of the entity. |
1 |
| Entity |
string |
The name of the entity. |
Dr. Wang |
| Type |
string |
The type of the entity. |
人物 |
| Description |
string |
The description of the entity. |
A former advisor at DeepMind. |
| FileName |
string |
The file name. |
my_doc.txt |
| Relations |
object |
||
| relations |
array<object> |
Details about the relationship edge. |
|
|
object |
Details about the relationship edge. |
||
| Id |
string |
The ID of the relationship edge. |
1 |
| SourceEntity |
string |
The source entity. |
DeepMind前顾问 |
| TargetEntity |
string |
The target entity. |
Dr. Wang |
| Description |
string |
The description of the relationship edge. |
Dr. Wang previously served as an advisor at DeepMind. |
| FileName |
string |
The file name. |
my_doc.txt |
Examples
Success response
JSON format
{
"RequestId": "ABB39CC3-4488-4857-905D-2E4A051D0521",
"Message": "success",
"Status": "success",
"Matches": {
"MatchList": [
{
"Id": "doca-1234",
"Content": "云原生数据仓库AnalyticDB PostgreSQL版提供简单、快速、经济高效的PB级云端数据仓库解决方案。",
"Metadata": {
"key": "{\\\"pic_id\\\":\\\"text\\\",\\\"pic_name\\\":\\\"text\\\",\\\"pic_url\\\":\\\"text\\\"}"
},
"FileName": "my_doc.txt",
"Score": 0.12345,
"RetrievalSource": 1,
"LoaderMetadata": "{\"page_pos\": 1}",
"FileURL": "https://xxx-cn-beijing.aliyuncs.com/image/test.png",
"RerankScore": 6.2345
}
]
},
"EmbeddingTokens": "100",
"Usage": {
"EmbeddingTokens": "475",
"EmbeddingEntries": "10"
},
"Entities": {
"entities": [
{
"Id": "1",
"Entity": "Dr. Wang",
"Type": "人物",
"Description": "A former advisor at DeepMind.",
"FileName": "my_doc.txt"
}
]
},
"Relations": {
"relations": [
{
"Id": "1",
"SourceEntity": "DeepMind前顾问",
"TargetEntity": "Dr. Wang",
"Description": "Dr. Wang previously served as an advisor at DeepMind.",
"FileName": "my_doc.txt\n"
}
]
}
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.