QueryKnowledgeBasesContent
Retrieves vectors and metadata from multiple specified document collections by using natural language statements, merges multi-channel recall results, and returns the combined results.
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 instance ID. Note
You can call the DescribeDBInstances operation to query the details of all AnalyticDB for PostgreSQL instances in a region, including instance IDs. |
gp-xxxxxxxxx |
| RegionId |
string |
Yes |
The region ID of the instance. |
cn-beijing |
| Content |
string |
Yes |
The text content used for retrieval. |
What is 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 configurable parameters when MergeMethod is set to RRF. |
|
| K |
integer |
No |
The k constant in the scoring algorithm |
60 |
| Weight |
object |
No |
The configurable parameters when MergeMethod is set to Weight. |
|
| Weights |
array |
No |
The weight array for each SourceCollection. |
|
|
number |
No |
The weight of each SourceCollection. |
0.5 |
|
| RerankFactor |
number |
No |
The reranking factor. If this parameter is not empty, the vector retrieval results are reranked. Valid values: 1 < RerankFactor <= 5. Note
|
2 |
| RerankModel |
object |
No |
The reranking model parameters for performing an additional reranking on the overall results after multi-channel merging. |
|
| Name |
string |
No |
The name of the reranking model. Valid values: qwen3-rerank, gte-rerank-v2. |
qwen3-rerank |
| Instruct |
string |
No |
This parameter can be set when RerankModel.Name is set to qwen3-rerank. Specifies a custom ranking task type description that guides the model to adopt different ranking strategies. |
Given a web search query, retrieve relevant passages that answer the query |
| SourceCollection |
array<object> |
Yes |
The information about the multiple collections to retrieve. |
|
|
array<object> |
No |
The knowledge base. |
||
| Collection |
string |
Yes |
The name of the document collection. Note
The document collection is created by calling the CreateDocumentCollection operation. You can call the ListDocumentCollections operation to view existing document collections. |
knowledge22 |
| Namespace |
string |
No |
The namespace. Note
You can create a namespace by calling the CreateNamespace operation and view the list by calling the ListNamespaces operation. |
ns_cloud_index |
| NamespacePassword |
string |
Yes |
The password of the namespace. Note
This value is specified by the CreateNamespace operation. |
ns_password |
| QueryParams |
object |
No |
The filter conditions for the data to query, in SQL WHERE clause format. |
|
| Filter |
string |
No |
The filter conditions for the data to query, in SQL WHERE clause format. This is an expression that returns a Boolean value (true or false). The conditions can be simple comparison operators such as equal to (=), not equal to (<> or !=), greater than (>), less than (<), greater than or equal to (>=), and less than or equal to (<=). They can also be more complex expressions combined with logical operators (AND, OR, NOT), as well as conditions that use keywords such as IN, BETWEEN, and LIKE. Note
|
id = 'llm-52tvykqt6u67iw73_j6ovptwjk7_file_6ce3da1f7e69495d9f491f2180c86973_11967297' |
| GraphEnhance |
boolean |
No |
Specifies 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. The default value is 60. |
60 |
| HybridSearch |
string |
No |
The multi-channel recall algorithm. Default value: empty (the scores from dense vectors and full-text retrieval are directly compared and sorted). Valid values:
|
Cascaded |
| HybridSearchArgs |
object |
No |
The algorithm parameters for multi-channel recall. RRF and Weight are supported. HybridPathsSetting specifies the recall paths: dense vectors (dense), sparse vectors (sparse), and full-text retrieval (fulltext). If this value is empty, dense vectors (dense) and full-text retrieval (fulltext) are used by default.
|
|
|
any |
No |
|||
| Metrics |
string |
No |
The method used to build the vector index. Valid values:
|
cosine |
| RecallWindow |
array |
No |
The recall window. If this value is not empty, the context of the retrieval results is included. The format is 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 parameter is not empty, the vector retrieval results are reranked. Valid values: 1 < RerankFactor <= 5. Note
|
2.0 |
| RerankModel |
object |
No |
The reranking model parameters. |
|
| Name |
string |
No |
The name of the rerank model. Valid values: |
qwen3-rerank |
| Instruct |
string |
No |
This parameter can be set only when |
Given a web search query, retrieve relevant passages that answer the query |
| RerankMetadataFields |
string |
No |
||
| TopK |
integer |
No |
The number of top results to return. |
776 |
| UseFullTextRetrieval |
boolean |
No |
Specifies whether to use full-text retrieval (dual-path recall). Default value: false, which indicates that only vector retrieval is used. |
false |
| OrderBy |
string |
No |
The field used for sorting. Default value: empty. The field must belong to metadata or a default field in the table, such as id. Supported formats: A single field, such as chunk_id. Multiple fields separated by commas, such as block_id, chunk_id. Descending order is supported, such as block_id DESC, chunk_id DESC. |
file_id,sort_num |
| Offset |
integer |
No |
The offset for paging query. |
20 |
| TopK |
integer |
No |
The number of top results to return after multi-channel recall merging. |
10 |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The request ID. |
ABB39CC3-4488-4857-905D-2E4A051D0521 |
| Message |
string |
The returned message. |
success |
| Status |
string |
The API execution status. Valid values:
|
success |
| Matches |
object |
||
| MatchList |
array<object> |
The individual record. |
|
|
array<object> |
The individual record. |
||
| Id |
string |
The unique ID of the vector data. |
doca-1234 |
| Content |
string |
The text content. |
AnalyticDB for PostgreSQL provides a simple, fast, and cost-effective PB-level cloud data warehousing solution. |
| Metadata |
object |
The metadata. |
|
|
string |
The value of a metadata entry. |
{\"pic_id\":\"text\",\"pic_name\":\"text\",\"pic_url\":\"text\"} |
|
| FileName |
string |
The file name. |
my_doc.txt |
| Score |
number |
The similarity score. The scoring algorithm depends on the distance metric ( |
0.12345 |
| RetrievalSource |
integer |
The retrieval source. Valid values: 1 (vector retrieval), 2 (full-text search), and 3 (dual-path retrieval). |
1 |
| LoaderMetadata |
string |
The metadata from the document loader. |
{"page_pos": 1} |
| FileURL |
string |
The public URL of the file. The URL is valid for 2 hours by default. You can specify a custom validity period by using the |
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 the input text is split. A token can be a word, a phrase, a punctuation mark, or a character. |
100 |
| Usage |
object |
The resource usage of this query. |
|
| EmbeddingTokens |
string |
The number of tokens used during vectorization. Note
A token is the smallest unit into which the input text is split. A token can be a word, a phrase, a punctuation mark, or a character. |
475 |
| EmbeddingEntries |
string |
The number of entries used during vectorization. Note
An entry refers to the number of items processed during vectorization of text or images. For example, processing text once counts as 1 entry, and processing an image once counts as 2 entries. |
10 |
| Entities |
object |
||
| entities |
array<object> |
The entity details. |
|
|
object |
The entity details. |
||
| Id |
string |
The entity ID. |
1 |
| Entity |
string |
The entity name. |
Dr. Wang |
| Type |
string |
The entity type. |
Person |
| Description |
string |
The entity description. |
A former advisor at DeepMind. |
| FileName |
string |
The file name. |
my_doc.txt |
| Relations |
object |
||
| relations |
array<object> |
The relationship edge details. |
|
|
object |
The relationship edge details. |
||
| Id |
string |
The ID of the relationship edge. |
1 |
| SourceEntity |
string |
The source entity. |
Former DeepMind advisor |
| 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 for PostgreSQL provides a simple, fast, and cost-effective PB-level cloud data warehousing solution.",
"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": "Person",
"Description": "A former advisor at DeepMind.",
"FileName": "my_doc.txt"
}
]
},
"Relations": {
"relations": [
{
"Id": "1",
"SourceEntity": "Former DeepMind advisor",
"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.