CreateDocumentCollection

Updated at:
Copy as MD

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

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

gp-xxxxxxxxx

ManagerAccount

string

Yes

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

Note

You can create an account in the console by navigating to Account Management, or by calling the CreateAccount operation.

testaccount

ManagerAccountPassword

string

Yes

The password of the management account.

testpassword

Namespace

string

No

The namespace. Default value: public.

Note

You can call the CreateNamespace operation to create a namespace, or call the ListNamespaces operation to view the namespace list.

mynamespace

Collection

string

Yes

The name of the document library to create.

Note

The name must comply with the object naming conventions of PostgreSQL.

document

RegionId

string

Yes

The region ID of the instance.

cn-hangzhou

EmbeddingModel

string

No

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

Note

Supported algorithms:

  • text-embedding-v3 (recommended, default): 1024, 768, or 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 dimension supported by the embedding algorithm.

1024

FullTextRetrievalFields

string

No

The fields used to retrieve data from the full-text index. Separate multiple fields with commas (,). The fields must be keys defined in Metadata.

title,page

Metadata

string

No

The metadata of the vector data, which is 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 type is not supported.

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

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

Parser

string

No

The tokenizer used to retrieve data from the full-text index. Default value: zh_cn.

zh_cn

Metrics

string

No

The distance metric used when building 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 in the HNSW algorithm. The operation automatically sets this value based on the vector dimensions. Manual configuration is generally not required.

Note

Valid values:

  • AnalyticDB for PostgreSQL V6.0 instances: 1 to 1000.

  • AnalyticDB for PostgreSQL V7.0 instances: 2 to 100. Default value: 16.

Note

Recommended values based on vector dimensions:

  • 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 size of the candidate set when building the index with the HNSW algorithm. The value must be greater than or equal to 2 × HNSW_M.

Note

Valid values:

  • AnalyticDB for PostgreSQL V6.0 instances: 40 to 4000.

  • AnalyticDB for PostgreSQL V7.0 instances: 4 to 1000. Default value: 64.

128

PqEnable

integer

No

Specifies whether to enable the Product Quantization (PQ) algorithm to accelerate index building. It is recommended to enable this feature when the data volume exceeds 500,000. Valid values:

  • 0: Disable.

  • 1: Enable (default).

1

ExternalStorage

integer

No

Specifies whether to use mmap to build the HNSW index. Default value: 0. If data deletion is not required and high data upload speed is needed, we recommend that you set this parameter to 1.

Valid values:

  • 0: Uses the default segment-page storage to build the index. In this mode, shared_buffer in PostgreSQL can be used for caching, and operations such as deletion and update are supported.

  • 1: Uses mmap to build the index. In this mode, operations such as deletion and update are not supported.

Important The ExternalStorage parameter is supported only in V6.0. It is not supported in V7.0.

Valid values:

  • 0
  • 1

0

MetadataIndices

string

No

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

title

EnableGraph

boolean

No

Specifies whether to enable knowledge graph construction. Default value: false.

Note

Before you use this parameter, the instance must be upgraded to a version that supports the graph engine. (During the public preview, submit a ticket to upgrade the version.)

true

LLMModel

string

No

The name of the LLM. Valid values:

  • knowledge-extract-standard: Default value.

  • knowledge-extract-mini

Note

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

knowledge-extract-standard

Language

string

No

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

  • Simplified Chinese: Simplified Chinese. Default value.

  • English: English.

Note

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

Simplified Chinese

EntityTypes

array

No

The list of entity types.

Note

This parameter is required when knowledge graph construction is enabled.

Location

string

No

The entity type.

Location

RelationshipTypes

array

No

The list of relationship edge types.

Note

This parameter is required when knowledge graph construction is enabled.

Occurred

string

No

The relationship edge type.

Occurs

SupportSparse

boolean

No

Specifies whether to support sparse vectors. Default value: false.

true

SparseVectorIndexConfig

object

No

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

Algorithm

string

No

The vector index algorithm.

Valid values:

  • hnswflat: HNSW index without quantization compression (default).

  • novam: Graph index without quantization compression, suitable for high-performance scenarios such as real-time recommendation.

hnswflat

HnswEfConstruction

integer

No

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

Note

This parameter is required only for AnalyticDB for PostgreSQL V7.0 instances, and the value must be greater than or equal to 2 × HNSW_M.

128

HnswM

integer

No

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

Note

Valid values:

  • AnalyticDB for PostgreSQL V6.0 instances: 1 to 1000.

  • AnalyticDB for PostgreSQL V7.0 instances: 2 to 100. Default value: 16.

Note

Recommended values based on vector dimensions:

  • 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

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

Algorithm

string

No

The vector index algorithm.

Valid values:

  • hnswflat: HNSW index without quantization compression (default).

  • novam: Graph index without quantization compression, suitable for high-performance scenarios such as real-time recommendation.

  • novad: Partitioned index with rabitq quantization, suitable for large-scale, low-cost retrieval scenarios.

hnswflat

VectorIndexConfig

object

No

The dense vector index configuration.

Nlist

integer

No

The number of lists (partitions) for Novad. Valid values: [2, 1073741824]. Default value: 256.

256

RabitqBits

integer

No

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

3

Response elements

Element

Type

Description

Example

object

Message

string

The returned message.

Successful

RequestId

string

The request ID.

ABB39CC3-4488-4857-905D-2E4A051D0521

Status

string

The execution status of the operation. Valid values:

  • success: The operation is successful.

  • fail: The operation fails.

successs

Examples

Success response

JSON format

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

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.