A vector bucket is a container for storing vector indexes and vector data. It serves as the basic storage unit for building and managing large-scale vector retrieval services.
This feature is currently available in the following regions: China (Shenzhen), China (Beijing), China (Hangzhou), China (Shanghai), China (Ulanqab), Singapore, China (Hong Kong), Indonesia (Jakarta), Germany (Frankfurt), US (Silicon Valley), and US (Virginia).
Create vector bucket
Each Alibaba Cloud account can create up to 10 vector buckets per region. To increase this quota, contact Technical Support.
Console
On the Vector Buckets page, click Create Vector Bucket.
Configure the bucket settings:
Vector bucket name: The name must be unique within the same region for your Alibaba Cloud account. It must be 3 to 32 characters long and can contain only lowercase letters, digits, and hyphens (-). The name cannot start or end with a hyphen.
Region: Select the region where the bucket will be located. This setting cannot be changed after creation. We recommend choosing the region closest to your workload to minimize latency.
Redundancy type: Defaults to zone-redundant storage for high reliability. Keep the default setting.
Endpoint: The system automatically generates dedicated endpoints for internet and internal network access. These endpoints are separate from those for standard OSS buckets.
Click OK to create the bucket.
ossutil
Create a vector bucket named examplebucket.
ossutil vectors-api put-vector-bucket --bucket examplebucketSDK
Python
import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.vectors as oss_vectors
parser = argparse.ArgumentParser(description="vector put bucket sample")
parser.add_argument('--region', help='The region in which the bucket is located.', required=True)
parser.add_argument('--bucket', help='The name of the bucket.', required=True)
parser.add_argument('--endpoint', help='The domain names that other services can use to access OSS')
parser.add_argument('--account_id', help='The account id.', required=True)
def main():
args = parser.parse_args()
# Loading credentials values from the environment variables
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Using the SDK's default configuration
cfg = oss.config.load_default()
cfg.credentials_provider = credentials_provider
cfg.region = args.region
cfg.account_id = args.account_id
if args.endpoint is not None:
cfg.endpoint = args.endpoint
vector_client = oss_vectors.Client(cfg)
result = vector_client.put_vector_bucket(oss_vectors.models.PutVectorBucketRequest(
bucket=args.bucket,
))
print(f'status code: {result.status_code},'
f' request id: {result.request_id},'
)
if __name__ == "__main__":
main()Go
package main
import (
"context"
"flag"
"log"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/vectors"
)
var (
region string
bucketName string
accountId string
)
func init() {
flag.StringVar(®ion, "region", "", "The region in which the vector bucket is located.")
flag.StringVar(&bucketName, "bucket", "", "The name of the vector bucket.")
flag.StringVar(&accountId, "account-id", "", "The ID of the vector account.")
}
func main() {
flag.Parse()
if len(bucketName) == 0 {
flag.PrintDefaults()
log.Fatalf("invalid parameters, bucket name required")
}
if len(region) == 0 {
flag.PrintDefaults()
log.Fatalf("invalid parameters, region required")
}
if len(accountId) == 0 {
flag.PrintDefaults()
log.Fatalf("invalid parameters, accountId required")
}
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region).WithAccountId(accountId)
client := vectors.NewVectorsClient(cfg)
request := &vectors.PutVectorBucketRequest{
Bucket: oss.Ptr(bucketName),
}
result, err := client.PutVectorBucket(context.TODO(), request)
if err != nil {
log.Fatalf("failed to put vector bucket %v", err)
}
log.Printf("put vector bucket result:%#v\n", result)
}API
Call the PutVectorBucket operation to create a vector bucket.
View vector bucket details
Console
On the Vector Buckets page, click the name of the target bucket.
On the Overview page, you can view the following information:
Basic information: Includes the bucket name, region, and creation time.
Endpoints: Endpoints for internet and internal network access.
ossutil
Get information about the vector bucket named examplebucket.
ossutil vectors-api get-vector-bucket --bucket examplebucketSDK
Python
import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.vectors as oss_vectors
parser = argparse.ArgumentParser(description="vector get bucket sample")
parser.add_argument('--region', help='The region where the bucket is located.', required=True)
parser.add_argument('--bucket', help='The name of the bucket.', required=True)
parser.add_argument('--endpoint', help='The endpoint used to access OSS.')
parser.add_argument('--account_id', help='The ID of your Alibaba Cloud account.', required=True)
def main():
args = parser.parse_args()
# Loading credentials values from the environment variables
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Using the SDK's default configuration
cfg = oss.config.load_default()
cfg.credentials_provider = credentials_provider
cfg.region = args.region
cfg.account_id = args.account_id
if args.endpoint is not None:
cfg.endpoint = args.endpoint
vector_client = oss_vectors.Client(cfg)
result = vector_client.get_vector_bucket(oss_vectors.models.GetVectorBucketRequest(
bucket=args.bucket,
))
print(f'status code: {result.status_code},'
f' request id: {result.request_id},'
f' bucket: {result.bucket_info},'
)
if __name__ == "__main__":
main()Go
package main
import (
"context"
"flag"
"log"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/vectors"
)
var (
region string
bucketName string
accountId string
)
func init() {
flag.StringVar(®ion, "region", "", "The region in which the vector bucket is located.")
flag.StringVar(&bucketName, "bucket", "", "The name of the vector bucket.")
flag.StringVar(&accountId, "account-id", "", "The ID of the vector account.")
}
func main() {
flag.Parse()
if len(bucketName) == 0 {
flag.PrintDefaults()
log.Fatalf("invalid parameters, bucket name required")
}
if len(region) == 0 {
flag.PrintDefaults()
log.Fatalf("invalid parameters, region required")
}
if len(accountId) == 0 {
flag.PrintDefaults()
log.Fatalf("invalid parameters, accounId required")
}
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region).WithAccountId(accountId)
client := vectors.NewVectorsClient(cfg)
request := &vectors.GetVectorBucketRequest{
Bucket: oss.Ptr(bucketName),
}
result, err := client.GetVectorBucket(context.TODO(), request)
if err != nil {
log.Fatalf("failed to get vector bucket %v", err)
}
log.Printf("get vector bucket result:%#v\n", result)
}API
Call the GetVectorBucket operation to retrieve information about a vector bucket.
List vector buckets
Console
Go to the Vector Buckets page to view all vector buckets in your Alibaba Cloud account.
ossutil
List all vector buckets in your account.
ossutil vectors-api list-vector-bucketsSDK
Python
import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.vectors as oss_vectors
parser = argparse.ArgumentParser(description="list vector buckets sample")
parser.add_argument('--region', help='The region in which the bucket is located.', required=True)
parser.add_argument('--endpoint', help='The domain names that other services can use to access OSS')
parser.add_argument('--account_id', help='The account id.', required=True)
def main():
args = parser.parse_args()
# Loading credentials values from the environment variables
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Using the SDK's default configuration
cfg = oss.config.load_default()
cfg.credentials_provider = credentials_provider
cfg.region = args.region
cfg.account_id = args.account_id
if args.endpoint is not None:
cfg.endpoint = args.endpoint
client = oss_vectors.Client(cfg)
# Create the Paginator for the ListVectorBuckets operation
paginator = client.list_vector_buckets_paginator()
# Iterate through the vector bucket pages
for page in paginator.iter_page(oss_vectors.models.ListVectorBucketsRequest(
)
):
for o in page.buckets:
print(f'Bucket: {o.name}, {o.location}')
if __name__ == "__main__":
main()Go
package main
import (
"context"
"flag"
"log"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/vectors"
)
var (
region string
accountId string
)
func init() {
flag.StringVar(®ion, "region", "", "The region in which the vector bucket is located.")
flag.StringVar(&accountId, "account-id", "", "The ID of the vector account.")
}
func main() {
flag.Parse()
if len(region) == 0 {
flag.PrintDefaults()
log.Fatalf("invalid parameters, region required")
}
if len(accountId) == 0 {
flag.PrintDefaults()
log.Fatalf("invalid parameters, accountId required")
}
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region).WithAccountId(accountId)
client := vectors.NewVectorsClient(cfg)
request := &vectors.ListVectorBucketsRequest{}
p := client.NewListVectorBucketsPaginator(request)
var i int
log.Println("Vector Buckets:")
for p.HasNext() {
i++
page, err := p.NextPage(context.TODO())
if err != nil {
log.Fatalf("failed to get page %v, %v", i, err)
}
// Log the buckets found.
for _, b := range page.Buckets {
log.Printf("Bucket:%v, %v, %v\n", oss.ToString(b.Name), oss.ToString(b.ResourceGroupId), oss.ToString(b.Location))
}
}
}API
Call the ListVectorBuckets operation to list all vector buckets in your Alibaba Cloud account.
Delete vector bucket
Before you delete a vector bucket, you must first delete all vector indexes and vector data within it. This operation is irreversible. Back up any important data before proceeding.
Console
On the Vector Buckets page, click the name of the target vector bucket.
In the left-side navigation pane, click Delete Bucket.
Follow the on-screen instructions to confirm the operation and remove all resources from the bucket.
After the resources are removed, click Delete Immediately.
ossutil
Delete the vector bucket named examplebucket.
ossutil vectors-api delete-vector-bucket --bucket examplebucketSDK
Python
import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.vectors as oss_vectors
parser = argparse.ArgumentParser(description="vector delete bucket sample")
parser.add_argument('--region', help='The region in which the bucket is located.', required=True)
parser.add_argument('--bucket', help='The name of the bucket.', required=True)
parser.add_argument('--endpoint', help='The domain names that other services can use to access OSS')
parser.add_argument('--account_id', help='The account ID.', required=True)
def main():
args = parser.parse_args()
# Load credentials from environment variables
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Initialize the SDK with default configuration
cfg = oss.config.load_default()
cfg.credentials_provider = credentials_provider
cfg.region = args.region
cfg.account_id = args.account_id
if args.endpoint is not None:
cfg.endpoint = args.endpoint
vector_client = oss_vectors.Client(cfg)
result = vector_client.delete_vector_bucket(oss_vectors.models.DeleteVectorBucketRequest(
bucket=args.bucket,
))
print(f'status code: {result.status_code},'
f' request id: {result.request_id},'
)
if __name__ == "__main__":
main()Go
package main
import (
"context"
"flag"
"log"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/vectors"
)
var (
region string
bucketName string
accountId string
)
func init() {
flag.StringVar(®ion, "region", "", "The region where the vector bucket is located.")
flag.StringVar(&bucketName, "bucket", "", "The name of the vector bucket.")
flag.StringVar(&accountId, "account-id", "", "The ID of the vector account.")
}
func main() {
flag.Parse()
if len(bucketName) == 0 {
flag.PrintDefaults()
log.Fatalf("invalid parameters, bucket name required")
}
if len(region) == 0 {
flag.PrintDefaults()
log.Fatalf("invalid parameters, region required")
}
if len(accountId) == 0 {
flag.PrintDefaults()
log.Fatalf("invalid parameters, accountId required")
}
// Load credentials from environment variables, region and account ID from flags
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region).WithAccountId(accountId)
// Initialize the VectorsClient
client := vectors.NewVectorsClient(cfg)
// Build the delete request
request := &vectors.DeleteVectorBucketRequest{
Bucket: oss.Ptr(bucketName),
}
// Call DeleteVectorBucket and handle the result
result, err := client.DeleteVectorBucket(context.TODO(), request)
if err != nil {
log.Fatalf("failed to delete vector bucket %v", err)
}
log.Printf("delete vector bucket result:%#v\n", result)
}API
Call the DeleteVectorBucket operation to delete a vector bucket.