All Products
Search
Document Center

AnalyticDB:CreateCollection

Last Updated:Feb 09, 2026

Create a vector collection.

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:CreateCollection

create

*Collection

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

None None

Request parameters

Parameter

Type

Required

Description

Example

DBInstanceId

string

No

The ID of the database instance.

Note

Call the DescribeDBInstances operation to list all AnalyticDB for PostgreSQL instances in the destination region.

gp-bp152460513z****

ManagerAccount

string

Yes

The name of the management account that has the rds_superuser permission.

Note

Call the CreateAccount operation to create an account.

testaccount

ManagerAccountPassword

string

Yes

The password of the management account.

testpassword

Namespace

string

No

The namespace.

Note

Create a namespace by calling the CreateNamespace operation. List namespaces by calling the ListNamespaces operation.

mynamespace

Collection

string

Yes

The name of the collection to create.

Note

The name must comply with PostgreSQL object naming rules.

document

Dimension

integer

No

The vector dimensions.

Note

If you specify this parameter, the system builds an index. The length of the Rows.Vector field in subsequent UpsertCollectionData calls must match this value. If you omit this parameter, call CreateVectorIndex later to build an index.

1024

FullTextRetrievalFields

string

No

The fields used for full-text search. Separate multiple fields with commas (,). Each field must be a key defined in the Metadata parameter.

title,content

Metadata

string

Yes

The metadata of the vector data, formatted as a JSON string in MAP format. Keys represent field names. Values represent data types.

Note

Supported data types

  • For the complete list, see Data types.

  • The money type is not supported.

Warning The id, vector, to_tsvector, and source fields are reserved. Do not use them.

{"title":"text","content":"text","response":"int"}

Parser

string

No

The tokenizer used for full-text search. Default value: zh_cn.

zh_cn

RegionId

string

Yes

The ID of the region where the instance resides.

cn-hangzhou

Metrics

string

No

The distance metric used when building the vector index. Valid values:

  • l2: Euclidean distance.

  • ip: Inner product distance.

  • cosine: Cosine similarity.

cosine

HnswM

integer

No

The maximum number of neighbors in the HNSW algorithm. The API sets this value automatically based on the vector dimensions. You usually do not need to set it manually.

Note

Valid values:

  • AnalyticDB for PostgreSQL 6.0: 1 to 1000.

  • AnalyticDB for PostgreSQL 7.0: 2 to 100. Default value: 16.

Note

We recommend these values based on vector dimensions:

  • ≤ 384: 16

  • 384 < dimension ≤ 768: 32

  • 768 < dimension ≤ 1024: 64

  • > 1024: 128

64

HnswEfConstruction

string

No

The candidate set size used when building the HNSW index. This value must be ≥ 2 × HNSW_M.

Note

Valid values:

  • AnalyticDB for PostgreSQL 6.0: 40 to 4000.

  • AnalyticDB for PostgreSQL 7.0: 4 to 1000. Default value: 64.

128

PqEnable

integer

No

Specifies whether to enable Product Quantization (PQ) to accelerate indexing. Enable PQ if your data volume exceeds 500,000 vectors. Valid values:

  • 0: Disabled.

  • 1: Enabled. Default value.

1

ExternalStorage

integer

No

Specifies whether to use memory-mapped files (mmap) to build the HNSW index. Default value: 0. Set this to 1 if you do not need to delete data and require high upload speed.

Valid values:

  • 0: Build the index using segment-page storage. This mode uses PostgreSQL shared_buffer for caching and supports deletion and update operations.

  • 1: Build the index using mmap. This mode does not support deletion or update operations.

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

0

WorkspaceId

string

No

The ID of the workspace that contains multiple database instances. This parameter and DBInstanceId cannot both be empty. If you specify both, WorkspaceId takes precedence.

gp-ws-*****

MetadataIndices

string

No

The scalar index fields. Separate multiple fields with commas (,). Each field must be a key defined in the Metadata parameter.

title

SupportSparse

boolean

No

Specifies whether sparse vectors are supported. Default value: false.

true

SparseVectorIndexConfig

object

No

The sparse vector index configuration. If you specify this parameter, a sparse vector index is created.

HnswM

integer

No

The maximum number of neighbors in the HNSW algorithm. The API sets this value automatically based on the vector dimensions. You usually do not need to set it manually.

Note

Valid values:

  • AnalyticDB for PostgreSQL 6.0: 1 to 1000.

  • AnalyticDB for PostgreSQL 7.0: 2 to 100. Default value: 16.

Note

We recommend these values based on vector dimensions:

  • ≤ 384: 16

  • 384 < dimension ≤ 768: 32

  • 768 < dimension ≤ 1024: 64

  • > 1024: 128

64

HnswEfConstruction

integer

No

The candidate set size used when building the HNSW index. Valid values: 4 to 1000. Default value: 64.

Note

This parameter is required only for AnalyticDB for PostgreSQL 7.0 instances. Its value must be ≥ 2 × HNSW_M.

128

Note

After you successfully create a vector collection, call DescribeCollection to view it.

Response elements

Element

Type

Description

Example

object

RequestId

string

The ID of the request.

ABB39CC3-4488-4857-905D-2E4A051D0521

Message

string

The detailed response message.

create successfully

Status

string

The creation status. Valid values:

  • success: The operation succeeded.

  • fail: The operation failed.

success

Examples

Success response

JSON format

{
  "RequestId": "ABB39CC3-4488-4857-905D-2E4A051D0521",
  "Message": "create successfully",
  "Status": "success"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.