All Products
Search
Document Center

AnalyticDB:CreateDocumentCollection

Last Updated:Feb 09, 2026

Creates a knowledge base.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

gpdb:CreateDocumentCollection

create

*Collection

acs:gpdb:{#regionId}:{#accountId}:collection/{#DBInstanceId}

None None

Request parameters

Parameter

Type

Required

Description

Example

DBInstanceId

string

Yes

The instance ID.

Note

Call the DescribeDBInstances API to view details of all AnalyticDB PostgreSQL instances in the destination region, including their instance IDs.

gp-xxxxxxxxx

ManagerAccount

string

Yes

The name of the management account with rds_superuser permissions.

Note

Create an account using the console > Account Management, or by calling the CreateAccount API.

testaccount

ManagerAccountPassword

string

Yes

The management account password.

testpassword

Namespace

string

No

The namespace. Default value: public.

Note

Create a namespace by calling the CreateNamespace API. View the list by calling the ListNamespaces API.

mynamespace

Collection

string

Yes

The name of the document collection to create.

Note

The name must comply with PostgreSQL object naming conventions.

document

RegionId

string

Yes

The ID of the region where the instance resides.

cn-hangzhou

EmbeddingModel

string

No

The embedding algorithm. Default value: text-embedding-v3.

Note

Supported algorithms:

  • text-embedding-v3 (Recommended, default value): 1024 dimensions, 768 dimensions, 512 dimensions

  • multimodal-embedding-v1 (Recommended): 1024 dimensions, multimodal embedding algorithm

  • text-embedding-v1: 1536 dimensions

  • text-embedding-v2: 1536 dimensions

  • text2vec (Not recommended): 1024 dimensions

  • m3e-base (Not recommended): 768 dimensions

  • m3e-small (Not recommended): 512 dimensions

  • clip-vit-b-32 (Not recommended): CLIP ViT-B/32 model, 512 dimensions, image embedding algorithm

  • clip-vit-b-16 (Not recommended): CLIP ViT-B/16 model, 512 dimensions, image embedding algorithm

  • clip-vit-l-14 (Not recommended): CLIP ViT-L/14 model, 768 dimensions, image embedding algorithm

  • clip-vit-l-14-336px (Not recommended): CLIP ViT-L/14@336px model, 768 dimensions, image embedding algorithm

  • clip-rn50 (Not recommended): CLIP RN50 model, 1024 dimensions, image embedding algorithm

  • clip-rn101 (Not recommended): CLIP RN101 model, 512 dimensions, image embedding algorithm

  • clip-rn50x4 (Not recommended): CLIP RN50x4 model, 640 dimensions, image embedding algorithm

  • clip-rn50x16 (Not recommended): CLIP RN50x16 model, 768 dimensions, image embedding algorithm

  • clip-rn50x64 (Not recommended): CLIP RN50x64 model, 1024 dimensions, image embedding algorithm

text-embedding-v1

Dimension

integer

No

The vector dimensions. The default value is the dimensions supported by the embedding algorithm.

1024

FullTextRetrievalFields

string

No

The fields for full-text index. Separate multiple fields with commas (,). The fields must be keys defined in Metadata.

title,page

Metadata

string

No

The metadata of vector data, a JSON string in MAP format. The key represents the field name, and the value represents the data type.

Note

Supported data types

  • For a list of data types, see Data Types.

  • The money data type is not supported.

Warning id, vector, doc_name, content, loader_metadata, source, and to_tsvector are reserved words. Do not use them.

{"title":"text","page":"int"}

Parser

string

No

The tokenizer for full-text index. Default value: zh_cn.

zh_cn

Metrics

string

No

The method for vector index building.

Value description:

  • l2: Euclidean distance.

  • ip: Dot product (inner product) distance.

  • cosine (Default): Cosine similarity.

cosine

HnswM

integer

No

The maximum number of neighbors in the HNSW algorithm. The API automatically sets this value based on the vector dimensions. Manual setting is generally not required.

Note

Value range:

  • For AnalyticDB PostgreSQL 6.0 instances: 1–1000.

  • For AnalyticDB PostgreSQL 7.0 instances: 2–100. Default value: 16.

Note

Set this value based on vector dimensions as follows:

  • Less than or equal to 384: 16

  • Greater than 384 and less than or equal to 768: 32

  • Greater than 768 and less than or equal to 1024: 64

  • Greater than 1024: 128

64

HnswEfConstruction

string

No

The candidate set size when building an HNSW index. The value must be >= 2*HNSW_M.

Note

Value range:

  • For AnalyticDB PostgreSQL 6.0 instances: 40–4000.

  • For AnalyticDB PostgreSQL 7.0 instances: 4–1000. Default value: 64.

128

PqEnable

integer

No

Enable or disable Product Quantization (PQ) algorithm acceleration for the index. Enable it if the data volume exceeds 500,000. Value description:

  • 0: Disable.

  • 1: Enable (default).

1

ExternalStorage

integer

No

Use mmap to build the HNSW index. Default value: 0. If data deletion is not required and high data upload performance is needed, set this parameter to 1.

Value description:

  • 0: By default, the index is built using segment-page storage. This mode allows PostgreSQL's shared_buffer for caching and supports operations such as deletion and update.

  • 1: The index is built using mmap. This mode does not support operations such as deletion and update.

Important The ExternalStorage parameter is only supported for version 6.0. It is not supported for version 7.0.

0

MetadataIndices

string

No

The scalar indexed fields. Separate multiple fields with commas (,). The fields must be keys defined in Metadata.

title

EnableGraph

boolean

No

Enable or disable knowledge graph building. Default value: false.

Note

Before using this parameter, upgrade the instance to a version that supports the graph engine. (During public preview, submit a ticket to upgrade the version.)

true

LLMModel

string

No

The LLM model name. Value description:

  • knowledge-extract-standard: Default value.

  • knowledge-extract-mini

Note

This parameter takes effect only when knowledge graph building is enabled.

knowledge-extract-standard

Language

string

No

The language used for knowledge graph building. Value description:

  • Simplified Chinese: Default value.

  • English.

Note

This parameter takes effect only when knowledge graph building is enabled.

Simplified Chinese

EntityTypes

array

No

The list of entity types.

Note

This parameter is required when knowledge graph building is enabled.

string

No

The entity type.

地点

RelationshipTypes

array

No

The list of relationship edge types.

Note

This parameter is required when knowledge graph building is enabled.

string

No

The relationship edge type.

发生

SupportSparse

boolean

No

Enable or disable sparse vector support. Default value: false.

true

SparseVectorIndexConfig

object

No

The sparse vector index configuration. If provided, a sparse vector index is created.

HnswM

integer

No

The maximum number of neighbors in the HNSW algorithm. The API automatically sets this value based on the vector dimensions. Manual setting is generally not required.

Note

Value range:

  • For AnalyticDB PostgreSQL 6.0 instances: 1–1000.

  • For AnalyticDB PostgreSQL 7.0 instances: 2–100. Default value: 16.

Note

Set this value based on vector dimensions as follows:

  • Less than or equal to 384: 16

  • Greater than 384 and less than or equal to 768: 32

  • Greater than 768 and less than or equal to 1024: 64

  • Greater than 1024: 128

64

HnswEfConstruction

integer

No

The candidate set size when building an HNSW index. Value range: 4–1000. Default value: 64.

Note

This value is required only for AnalyticDB PostgreSQL 7.0 instances, and the value must be >= 2*HNSW_M.

128

SparseRetrievalFields

string

No

The metadata fields used to build sparse vectors. Separate multiple fields with commas (,). The fields must be keys defined in Metadata.

title,abstract

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

ABB39CC3-4488-4857-905D-2E4A051D0521

Message

string

The message returned by the operation.

Successful

Status

string

The API execution status. Values:

  • success: Execution successful.

  • fail: Execution failed.

successs

Examples

Success response

JSON format

{
  "RequestId": "ABB39CC3-4488-4857-905D-2E4A051D0521",
  "Message": "Successful",
  "Status": "successs"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.