AnalyticDB for PostgreSQL provides vector-related APIs for database initialization, namespace and collection management, data upload, and vector retrieval.
Initialize vector database
Initialize the AnalyticDB for PostgreSQL vector database before use. This is a one-time operation per instance that completes the following tasks:
-
Creates a database named
knowledgebasefor storing all vector data. -
Creates functions related to Chinese word segmentation and retrieval for full-text index in this database.
Supported API: InitVectorDatabase - Initialize vector database.
Manage namespaces
A namespace maps to a schema in the database and serves as a prerequisite for creating document repositories. When you create a namespace, specify the NamespacePassword parameter. The AnalyticDB for PostgreSQL service automatically creates a user with the same name as the namespace based on this password, restricting access to data within that namespace.
Namespaces enable tenant-level data isolation. We recommend non-public namespaces for better security and management flexibility.
Namespace APIs:
LowLevel APIs
If you have integrated your own vector models and want to interact directly with vector data, use LowLevel APIs for greater flexibility and control.
Manage collections
A collection belongs to a namespace and stores vector data. In the database, a collection maps to a table with predefined columns for IDs, vector data, and full-text retrieval data. Additional schema fields can be defined through the Metadata parameter.
You can create vector, full-text, and scalar indexes when creating a collection, or add them later through the index management API.
Collection APIs:
Upload vector data
After creating a collection, you can upload vector data to it.
-
For uploads up to 10 MB, use the following API:
-
For uploads between 10 MB and 200 MB, use the following APIs:
-
Cancel upload API:
CancelUpsertCollectionDataJob - Cancel asynchronous vector data upload task
Retrieve vectors
After uploading vector data, use the following API to perform vector retrieval, full-text retrieval, dual-path recall, and fusion queries:
Manage vector data
Manage uploaded vector data with the following APIs:
HighLevel APIs
If you have raw documents or text and want to leverage AnalyticDB for PostgreSQL's built-in document understanding, chunking, embedding, and reranking capabilities, use HighLevel APIs.
Manage document collections
A document collection is similar to a vector collection and maps to a table in the database. It stores text chunks and vector data. Unlike vector collections, document collections require a vector model instead of vector dimensions at creation time.
Document collection APIs:
Upload documents
After creating a document collection, you can upload documents or chunks.
-
If your documents are already chunked and you only need AnalyticDB for PostgreSQL's embedding capability, upload them with the following API:
-
For raw documents or images, use the following asynchronous APIs:
Retrieve documents
Retrieve uploaded document content with the following API:
Manage documents
Manage uploaded documents with the following APIs:
Embedding
Vectorizes request text using the TextEmbedding model and returns the vector data without storing it in the database.
Rerank
Scores and sorts multiple chunks semantically using the Rerank model, improving ranking accuracy over vector or full-text retrieval alone.
Index management
Create or delete vector, full-text, and scalar indexes for a collection with the following APIs: