All Products
Search
Document Center

AnalyticDB:CreateDocumentCollection

Last Updated:Apr 14, 2026

Create 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 ID of the instance.

Note

You can call the DescribeDBInstances operation to query the details of all AnalyticDB for PostgreSQL instances in the target region, including instance IDs.

gp-xxxxxxxxx

ManagerAccount

string

Yes

The name of the manager account that has rds_superuser permissions.

Note

You can create an account in the console on the **Account Management** page or by calling the CreateAccount operation.

testaccount

ManagerAccountPassword

string

Yes

The password for the manager account.

testpassword

Namespace

string

No

The namespace. The default value is public.

Note

You can call the CreateNamespace operation to create a namespace and the ListNamespaces operation to list namespaces.

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 region ID of the instance.

cn-hangzhou

EmbeddingModel

string

No

The embedding model. The default value is text-embedding-v3.

Note

Supported models:

  • text-embedding-v3 (Recommended, Default): 1,024, 768, or 512 dimensions

  • multimodal-embedding-v1 (Recommended): 1,024 dimensions, a multimodal embedding model

  • text-embedding-v1: 1,536 dimensions

  • text-embedding-v2: 1,536 dimensions

  • text2vec (Not recommended): 1,024 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, an image embedding model

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

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

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

  • clip-rn50 (Not recommended): CLIP RN50 model, 1,024 dimensions, an image embedding model

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

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

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

  • clip-rn50x64 (Not recommended): CLIP RN50x64 model, 1,024 dimensions, an image embedding model

text-embedding-v1

Dimension

integer

No

The vector dimension. If you omit this parameter, the system uses a default dimension for the selected EmbeddingModel.

1024

FullTextRetrievalFields

string

No

The metadata fields to use for full-text search. These fields must be keys defined in Metadata. Separate multiple fields with a comma (,).

title,page

Metadata

string

No

The metadata schema for the vector data, specified as a JSON map where keys are field names and values are data types.

Note

Supported data types

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

  • The money data type is not supported.

Warning The following fields are reserved and cannot be used: id, vector, doc_name, content, loader_metadata, source, and to_tsvector.

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

Parser

string

No

The tokenizer for full-text search. The default value is zh_cn.

zh_cn

Metrics

string

No

The distance metric for the vector index.

Valid values:

  • l2: Euclidean distance.

  • ip: dot product (inner product) distance.

  • cosine (Default): cosine similarity.

cosine

HnswM

integer

No

The maximum number of neighbors (M) for the HNSW algorithm. You do not typically need to set this parameter, as the system automatically sets it based on the vector dimension.

Note

Value range:

  • For AnalyticDB for PostgreSQL V6.0 instances: 1 to 1,000.

  • For AnalyticDB for PostgreSQL V7.0 instances: 2 to 100. The default value is 16.

Note

We recommend that you set this parameter based on the vector dimension:

  • If the dimension is 384 or less: 16

  • If the dimension is greater than 384 and less than or equal to 768: 32

  • If the dimension is greater than 768 and less than or equal to 1,024: 64

  • If the dimension is greater than 1,024: 128

64

HnswEfConstruction

string

No

The size of the candidate set (ef_construction) for HNSW index construction. The value must be greater than or equal to 2 * HnswM.

Note

Value range:

  • For AnalyticDB for PostgreSQL V6.0 instances: 40 to 4,000.

  • For AnalyticDB for PostgreSQL V7.0 instances: 4 to 1,000. The default value is 64.

128

PqEnable

integer

No

Specifies whether to enable the PQ (product quantization) algorithm to accelerate indexing. This is recommended for datasets with over 500,000 entries. Valid values:

  • 0: Disables the feature.

  • 1: Enables the feature. This is the default value.

1

ExternalStorage

integer

No

Specifies whether to use memory-mapped files (mmap) to build the HNSW index. The default value is 0. Setting this to 1 is recommended if you do not need to delete data and require high upload performance.

Valid values:

  • 0: Builds the index by using segmented page storage. This mode supports delete and update operations and can use the shared_buffer in PostgreSQL for caching. This is the default value.

  • 1: Builds the index by using mmap. This mode does not support delete or update operations.

Important The ExternalStorage parameter is supported only by AnalyticDB for PostgreSQL V6.0 instances. It is not supported by V7.0 instances.

0

MetadataIndices

string

No

The metadata fields on which to create scalar indexes. These fields must be keys defined in Metadata. Separate multiple fields with a comma (,).

title

EnableGraph

boolean

No

Specifies whether to build a knowledge graph. The default value is false.

Note

To use this parameter, you must first upgrade your instance to a version that supports the graph engine. During the public preview period, submit a ticket to request an upgrade.

true

LLMModel

string

No

The name of the LLM model. Valid values:

  • knowledge-extract-standard: The default value.

  • knowledge-extract-mini

Note

This parameter takes effect only when EnableGraph is set to true.

knowledge-extract-standard

Language

string

No

The language used to build the knowledge graph. Valid values:

  • Simplified Chinese: The default value.

  • English

Note

This parameter takes effect only when EnableGraph is set to true.

Simplified Chinese

EntityTypes

array

No

A list of entity types.

Note

This parameter is required when EnableGraph is set to true.

string

No

An entity type.

Location

RelationshipTypes

array

No

A list of relationship types.

Note

This parameter is required when EnableGraph is set to true.

string

No

A relationship type.

Occurred

SupportSparse

boolean

No

Specifies whether to support sparse vectors. The default value is false.

true

SparseVectorIndexConfig

object

No

Configuration for the sparse vector index. Specifying this parameter creates the index.

HnswM

integer

No

The maximum number of neighbors (M) for the HNSW algorithm. You do not typically need to set this parameter, as the system automatically sets it based on the vector dimension.

Note

Value range:

  • For AnalyticDB for PostgreSQL V6.0 instances: 1 to 1,000.

  • For AnalyticDB for PostgreSQL V7.0 instances: 2 to 100. The default value is 16.

Note

We recommend that you set this parameter based on the vector dimension:

  • If the dimension is 384 or less: 16

  • If the dimension is greater than 384 and less than or equal to 768: 32

  • If the dimension is greater than 768 and less than or equal to 1,024: 64

  • If the dimension is greater than 1,024: 128

64

HnswEfConstruction

integer

No

The size of the candidate set (ef_construction) for HNSW index construction. Valid values: 4 to 1,000. The default value is 64.

Note

This parameter is applicable only to AnalyticDB for PostgreSQL V7.0 instances, and its value must be greater than or equal to 2 * HnswM.

128

Algorithm

string

No

The vector index algorithm.

Valid values:

  • hnswflat: An HNSW index without quantization compression. This is the default value.

  • novam: A graph index without quantization compression. This algorithm is suitable for high-performance scenarios such as real-time recommendation.

hnswflat

SparseRetrievalFields

string

No

The metadata fields used to build the sparse vector. These fields must be keys defined in Metadata. Separate multiple fields with a comma (,).

title,abstract

Algorithm

string

No

The vector index algorithm.

Valid values:

  • hnswflat: An HNSW index without quantization compression. This is the default value.

  • novam: A graph index without quantization compression. This algorithm is suitable for high-performance scenarios such as real-time recommendation.

  • novad: A partitioned index with rabitq quantization. This algorithm is suitable for large-scale, low-cost retrieval scenarios.

hnswflat

VectorIndexConfig

object

No

Configuration for the dense vector index.

Nlist

integer

No

The number of lists (partitions) for the novad algorithm. Valid values: [2, 1073741824]. The default value is 256.

256

RabitqBits

integer

No

The number of bits used for rabitq compression. Valid values: [1, 8]. The default value is 3.

3

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

ABB39CC3-4488-4857-905D-2E4A051D0521

Message

string

The response message.

Successful

Status

string

The status of the operation. Valid values:

  • success: The operation succeeded.

  • fail: The operation 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.