Retrieves vector data and metadata from a document collection by using natural statements.
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:QueryContent | create | *Document acs:gpdb:{#regionId}:{#accountId}:document/{#DBInstanceId} |
| none |
Request parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| DBInstanceId | string | Yes | Instance ID. Note
You can call the DescribeDBInstances API to view details of all AnalyticDB for PostgreSQL instances in the target region, including the instance ID.
| gp-xxxxxxxxx |
| Namespace | string | No | Namespace, default is public. Note
You can create a namespace using the CreateNamespace API and view the list of namespaces using the ListNamespaces API.
| mynamespace |
| Collection | string | Yes | Document collection name. Note
Created by the CreateDocumentCollection API. You can use the ListDocumentCollections API to view the list of created document collections.
| document |
| RegionId | string | Yes | The region ID where the instance is located. | cn-hangzhou |
| NamespacePassword | string | Yes | Password for the namespace. Note
This value is specified in the CreateNamespace API.
| testpassword |
| Content | string | No | Text content for retrieval. | What is ADBPG? |
| Filter | string | No | Filter condition for the data to be queried, in SQL WHERE format. It is an expression that returns a boolean value (true or false). The 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), and conditions using keywords like IN, BETWEEN, LIKE, etc. Note
| title = 'test' AND name like 'test%' |
| RecallWindow | array | No | Recall window. When this value is not empty, it adds context to the returned search results. The format is an array of 2 elements: List<A, B>, where -10 <= A <= 0 and 0 <= B <= 10. Note
| |
| integer | No | Recall window size. | [-5, 5] | |
| TopK | integer | No | The number of the returned top results. | 10 |
| RerankFactor | double | No | Re-ranking factor. When this value is not empty, it will re-rank the vector search results. The value range is 1 < RerankFactor <= 5. Note
| 2 |
| UseFullTextRetrieval | boolean | No | Whether to use full-text retrieval (dual recall). Default is false, which means only vector retrieval is used. | true |
| Metrics | string | No | Similarity algorithm used during retrieval. If this value is empty, the algorithm specified at the time of knowledge base creation is used. It is recommended not to set this unless there is a specific need. Note
Value description:
| cosine |
| FileName | string | No | In image search scenarios, the source file name of the image to be searched. Note
The image file must have a file extension. Currently supported image extensions: bmp, jpg, jpeg, png, tiff.
| test.jpg |
| FileUrl | string | No | In image search scenarios, the publicly accessible URL of the image file. Note
The image file must have a file extension. Currently supported image extensions: bmp, jpg, jpeg, png, tiff.
| https://xx/myImage.jpg |
| IncludeVector | boolean | No | Whether to return vectors. Default is false. Note
| true |
| HybridSearch | string | No | Dual 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. | { "RRF": { "k": 60 } } | |
| IncludeMetadataFields | string | No | The metadata fields to be returned. Separate multiple fields with commas (,). This parameter is empty by default. | title,page |
| IncludeFileUrl | boolean | No | Specifies whether to return the URL of the document. Default value: false. | false |
| UrlExpiration | string | No | The validity period of the returned image URL. Note
Value Description
| 7200s |
| GraphEnhance | boolean | No | Whether to enable knowledge graph enhancement. Default value: false. | false |
| GraphSearchArgs | object | No | The search parameters of the knowledge graph. | |
| GraphTopK | integer | No | The number of top entities and relationship edges. Default value: 60. | 60 |
| OrderBy | string | No | The fields by which to sort the results. This parameter is empty by default. The field must be either a metadata field or a default field in the table (e.g., id). Supported formats include: Single field, such as chunk_id. Multiple fields that are separated by commas (,), such as block_id,chunk_id. Descending order is supported, e.g., block_id DESC, chunk_id DESC. | created_at |
| Offset | integer | No | Offset, used for paginated queries. | 0 |
Response parameters
Examples
Sample success responses
JSONformat
{
"RequestId": "ABB39CC3-4488-4857-905D-2E4A051D0521",
"Message": "success",
"Status": "success",
"Matches": {
"MatchList": [
{
"Id": "doca-1234",
"Content": "Cloud-native data warehouse AnalyticDB PostgreSQL Edition provides a simple, fast, and cost-effective PB-level cloud data warehouse solution.",
"Metadata": {
"key": {
"title": "test"
}
},
"Vector": {
"VectorList": [
0
]
},
"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
}
]
},
"WindowMatches": {
"windowMatches": [
{
"WindowMatch": {
"windowMatch": [
{
"Id": "doca-2345",
"Content": "AnalyticDB for PostgreSQL is a cloud-native data warehouse service that provides large-scale parallel processing (MPP) capabilities for massive online data analysis.",
"Metadata": {
"key": {
"title": "test"
}
},
"FileName": "my_doc.txt",
"LoaderMetadata": {
"page_pos": 2
}
}
]
}
}
]
},
"EmbeddingTokens": 100,
"Usage": {
"EmbeddingTokens": 100,
"EmbeddingEntries": 10
},
"Entities": {
"entities": [
{
"Id": 1,
"Entity": "Dr. Wang",
"Type": "Figure\n",
"Description": "A former advisor at DeepMind.",
"FileName": "my_doc.txt"
}
]
},
"Relations": {
"relations": [
{
"Id": 1,
"SourceEntity": "Former DeepMind consultant\n",
"TargetEntity": "Dr. Wang",
"Description": "Dr. Wang previously served as an advisor at DeepMind.",
"FileName": "my_doc.txt\n"
}
]
}
}Error codes
For a list of error codes, visit the Service error codes.
Change history
| Change time | Summary of changes | Operation |
|---|---|---|
| 2024-07-18 | The request parameters of the API has changed | View Change Details |
| 2024-04-29 | The request parameters of the API has changed | View Change Details |
| 2024-04-22 | The request parameters of the API has changed | View Change Details |
| 2024-02-19 | The request parameters of the API has changed. The response structure of the API has changed | View Change Details |
| 2024-01-17 | The request parameters of the API has changed. The response structure of the API has changed | View Change Details |
