A vector bucket is a container for storing vector indexes and vector data, serving as the fundamental storage unit for building and managing large-scale vector retrieval services.
This feature is available in the China (Shenzhen), China (Qingdao), China (Beijing), China (Hangzhou), China (Shanghai), China (Ulanqab), Singapore, China (Hong Kong), Indonesia (Jakarta), Germany (Frankfurt), US (Silicon Valley), and US (Virginia) regions.
Create vector bucket
A single Alibaba Cloud account can create a maximum of 100 vector buckets in a region.
Console
On the Vector Buckets page, click Create a Vector Bucket.
Configure the bucket:
Vector Bucket Name: The name must be unique per region for an Alibaba Cloud account. The name must be 3 to 32 characters long and can contain only lowercase letters, digits, and hyphens (-). It cannot start or end with a hyphen.
Region: Select the region for the bucket. This setting cannot be changed after the bucket is created. To reduce access latency, select the region closest to your business.
Redundancy Type: Zone-redundant storage is used by default to ensure high reliability. No changes are required.
Endpoint: The system automatically generates an endpoint for the bucket. The service provides separate public and internal endpoints isolated from those of standard OSS buckets.
Click OK to create the bucket.
ossutil
Create a vector bucket named examplebucket.
ossutil vectors-api put-vector-bucket --bucket examplebucket
SDK
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 endpoint for accessing OSS.', required=False)
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()
# Use 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
cfg.use_internal_endpoint = True # Set this to False or delete this line if you want to access OSS over the public network.
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 account ID.")
}
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).
// To use a public endpoint, set this parameter to false or remove this line.
WithUseInternalEndpoint(true)
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)
}Java
import com.aliyun.sdk.service.oss2.credentials.CredentialsProvider;
import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.vectors.OSSVectorsClient;
import com.aliyun.sdk.service.oss2.vectors.models.PutVectorBucketRequest;
import com.aliyun.sdk.service.oss2.vectors.models.PutVectorBucketResult;
public class PutVectorBucketSample {
public static void main(String[] args) throws Exception {
CredentialsProvider provider = new EnvironmentVariableCredentialsProvider();
try (OSSVectorsClient client = OSSVectorsClient.newBuilder()
.region("cn-hangzhou")
.accountId("1234567890")
.credentialsProvider(provider)
.build()) {
PutVectorBucketRequest request = PutVectorBucketRequest.newBuilder()
.bucket("examplebucket")
.build();
PutVectorBucketResult result = client.putVectorBucket(request);
System.out.printf("status code: %d, request id: %s%n", result.statusCode(), result.requestId());
}
}
}API
Call the PutVectorBucket API operation to create a vector bucket.
Vector bucket information
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: The public and internal endpoints.
ossutil
View information about the vector bucket named examplebucket.
ossutil vectors-api get-vector-bucket --bucket examplebucket
SDK
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 for accessing 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()
# Use 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
cfg.use_internal_endpoint = True # To access OSS over the public network, set this parameter to False or remove this line.
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 Alibaba Cloud 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).
// To access the bucket over the public network, set this to false or remove this line.
WithUseInternalEndpoint(true)
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)
}Java
import com.aliyun.sdk.service.oss2.credentials.CredentialsProvider;
import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.vectors.OSSVectorsClient;
import com.aliyun.sdk.service.oss2.vectors.models.GetVectorBucketRequest;
import com.aliyun.sdk.service.oss2.vectors.models.GetVectorBucketResult;
public class GetVectorBucketSample {
public static void main(String[] args) throws Exception {
CredentialsProvider provider = new EnvironmentVariableCredentialsProvider();
try (OSSVectorsClient client = OSSVectorsClient.newBuilder()
.region("cn-hangzhou")
.accountId("1234567890")
.credentialsProvider(provider)
.build()) {
GetVectorBucketRequest request = GetVectorBucketRequest.newBuilder()
.bucket("examplebucket")
.build();
GetVectorBucketResult result = client.getVectorBucket(request);
System.out.printf("status code: %d, request id: %s%n", result.statusCode(), result.requestId());
}
}
}API
Call the GetVectorBucket API operation to retrieve information about a vector bucket.
List vector buckets
Console
Navigate to the Vector Buckets page to view all vector buckets in your Alibaba Cloud account.
ossutil
List all vector buckets owned by the requester.
ossutil vectors-api list-vector-buckets
SDK
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
cfg.use_internal_endpoint = True # To access OSS over the public network, set this parameter to False or delete this line.
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, accounId required")
}
cfg := oss.LoadDefaultConfig().
WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
WithRegion(region).WithAccountId(accountId).
// To access the service over the public network, set this to false or remove this line.
WithUseInternalEndpoint(true)
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))
}
}
}Java
import com.aliyun.sdk.service.oss2.credentials.CredentialsProvider;
import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.vectors.OSSVectorsClient;
import com.aliyun.sdk.service.oss2.vectors.models.ListVectorBucketsRequest;
import com.aliyun.sdk.service.oss2.vectors.models.ListVectorBucketsResult;
public class ListVectorBucketsSample {
public static void main(String[] args) throws Exception {
CredentialsProvider provider = new EnvironmentVariableCredentialsProvider();
try (OSSVectorsClient client = OSSVectorsClient.newBuilder()
.region("cn-hangzhou")
.accountId("1234567890")
.credentialsProvider(provider)
.build()) {
ListVectorBucketsRequest request = ListVectorBucketsRequest.newBuilder()
.build();
ListVectorBucketsResult result = client.listVectorBuckets(request);
System.out.printf("status code: %d, request id: %s%n", result.statusCode(), result.requestId());
}
}
}API
Call the ListVectorBuckets API operation to list all vector buckets in your Alibaba Cloud account.
Delete vector bucket
Before you delete a vector bucket, you must delete all vector indexes and vector data it contains. This operation is irreversible. Back up any important data before you proceed.
Console
On the Vector Buckets page, find and click the name of the vector bucket you want to delete.
In the left-side navigation pane, click Delete Bucket.
Follow the on-screen instructions to delete all resources in the bucket.
After all resources are deleted, click Delete Immediately.
ossutil
Delete the vector bucket named examplebucket.
ossutil vectors-api delete-vector-bucket --bucket examplebucket
SDK
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 of the bucket.', required=True)
parser.add_argument('--bucket', help='The name of the bucket.', required=True)
parser.add_argument('--endpoint', help='The OSS access endpoint.')
parser.add_argument('--account_id', help='The ID of your Alibaba Cloud account.', required=True)
def main():
args = parser.parse_args()
# Load credentials from environment variables
credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()
# Use 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
cfg.use_internal_endpoint = True # To access OSS over the public network, set this to False or delete this line.
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 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 account that contains the vector bucket.")
}
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).
// To use public access, set this parameter to false or remove this line.
WithUseInternalEndpoint(true)
client := vectors.NewVectorsClient(cfg)
request := &vectors.DeleteVectorBucketRequest{
Bucket: oss.Ptr(bucketName),
}
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)
}Java
import com.aliyun.sdk.service.oss2.credentials.CredentialsProvider;
import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.vectors.OSSVectorsClient;
import com.aliyun.sdk.service.oss2.vectors.models.DeleteVectorBucketRequest;
import com.aliyun.sdk.service.oss2.vectors.models.DeleteVectorBucketResult;
public class DeleteVectorBucketSample {
public static void main(String[] args) throws Exception {
CredentialsProvider provider = new EnvironmentVariableCredentialsProvider();
try (OSSVectorsClient client = OSSVectorsClient.newBuilder()
.region("cn-hangzhou")
.accountId("1234567890")
.credentialsProvider(provider)
.build()) {
DeleteVectorBucketRequest request = DeleteVectorBucketRequest.newBuilder()
.bucket("examplebucket")
.build();
DeleteVectorBucketResult result = client.deleteVectorBucket(request);
System.out.printf("status code: %d, request id: %s%n", result.statusCode(), result.requestId());
}
}
}API
Call the DeleteVectorBucket API operation to delete a vector bucket.