CreateVectorIndex

更新时间:
复制 MD 格式

Creates an index for 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:CreateVectorIndex

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 view the details of all AnalyticDB for PostgreSQL instances in a specific region, including the instance ID.

gp-xxxxxxxxx

Collection

string

Yes

The collection name.

Note

You can call the ListCollections operation to list all collections.

document

Dimension

integer

No

The vector dimension.

Note
  • This parameter is required for dense vectors.

  • This value must match the length of the Rows.Vector data provided when calling the UpsertCollectionData operation.

1024

ManagerAccount

string

Yes

The name of the management account that has rds_superuser permissions.

Note

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

testaccount

ManagerAccountPassword

string

Yes

The password of the management account.

testpassword

Metrics

string

No

The distance metric used to build the vector index. Valid values:

  • l2: euclidean distance

  • ip: dot product (inner product)

  • cosine: cosine similarity

Note

Sparse vectors support only ip.

cosine

Namespace

string

No

The namespace. The default value is public.

Note

You can call the ListNamespaces operation to list all namespaces.

mynamespace

RegionId

string

Yes

The region ID of the instance.

cn-hangzhou

PqEnable

integer

No

Specifies whether to enable Product Quantization (PQ) to accelerate indexing. Recommended for collections with over 500,000 vectors. Valid values:

  • 0: Disabled.

  • 1: Enabled. (Default)

1

HnswM

integer

No

The maximum number of neighbors for the Hierarchical Navigable Small World (HNSW) algorithm. The system automatically sets this value based on the vector dimension. You do not typically need to configure this parameter manually.

Note

Valid values:

  • 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 the following values based on the vector dimension:

  • For dimensions of 384 or less: 16

  • For dimensions from 385 to 768: 32

  • For dimensions from 769 to 1,024: 64

  • For dimensions greater than 1,024: 128

64

HnswEfConstruction

integer

No

The size of the candidate set for the HNSW algorithm during index construction. The value must be in the range of 4 to 1,000. The default value is 64.

Note

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

128

ExternalStorage

integer

No

Specifies whether to use mmap to build the HNSW index. The default value is 0. Set this to 1 for high-performance data uploads in scenarios where data deletion is not required.

Valid values:

  • 0: (Default) Builds the index by using segmented page storage. This mode uses the shared_buffer in PostgreSQL for caching and supports delete and update operations.

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

Important The ExternalStorage parameter is supported only by AnalyticDB for PostgreSQL V6.0.

0

Type

string

No

The vector type. Valid values:

  • Dense: (Default) a dense vector

  • Sparse: a sparse vector

Dense

Algorithm

string

No

The vector indexing algorithm.

Valid values:

  • hnswflat: (Default) An HNSW index that does not use quantization compression.

  • novam: A graph-based index that does not use quantization compression. This algorithm is suitable for high-performance scenarios, such as real-time recommendations.

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

hnswflat

Nlist

integer

No

The number of lists (partitions) for the Novad algorithm. The value must be in the range of 2 to 1,073,741,824. The default value is 256.

256

RabitqBits

integer

No

The number of bits for rabitq compression. The valid range is 1 to 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 request. Valid values:

  • success: The request was successful.

  • fail: The request failed.

success

Examples

Success response

JSON format

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

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.