Tüm Ürünler
Search
Belge Merkezi

:Vektör dizini alma (Go SDK V2)

Son Güncelleme:Oct 02, 2026

Belirtilen bir vektör dizinine ilişkin bilgileri almak için Go SDK V2 ile GetVectorIndex işlemini çağırın.

İzinler

Alibaba Cloud hesapları varsayılan olarak tam izne sahiptir. RAM kullanıcılarının ve RAM rollerinin yetkilendirilmesi için bir RAM ilkesi veya bir paket ilkesi tanımlamanız gerekir.


API


Eylem


Açıklama


GetVectorIndex


oss:GetVectorIndex


Vektör dizini bilgilerini alır.

Yöntem tanımı

func (c *VectorsClient) GetVectorIndex(ctx context.Context, request *GetVectorIndexRequest, optFns ...func(*oss.Options)) (*GetVectorIndexResult, error) 

İstek parametreleri


Parametre


Tür


Açıklama


ctx


context.Context


İstek bağlamı.


request


*GetVectorIndexRequest


Paket adı ve dizin adını içeren istek parametreleri. Daha fazla bilgi için bkz. GetVectorIndexRequest.


optFns


...func(*Options)

(İsteğe bağlı) İşlem düzeyindeki yapılandırma parametreleri.

Daha fazla bilgi için bkz. Options.

Dönüş değerleri


Parametre


Tür


Açıklama


result


*GetVectorIndexResult


İşlem sonucu. Yalnızca err değeri nil olduğunda geçerlidir. Daha fazla bilgi için bkz. GetVectorIndexResult.


err


error


Hata mesajı. Başarılı olursa nil döndürür.

Örnek kod

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
	indexName  string
	accountId  string
)

func init() {
	flag.StringVar(&region, "region", "", "The region where the bucket is located.")
	flag.StringVar(&bucketName, "bucket", "", "The name of the bucket.")
	flag.StringVar(&indexName, "index", "", "The name of the vector index.")
	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(indexName) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, index 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 service over a public endpoint, set this to false or remove this line.
		WithUseInternalEndpoint(true)

	client := vectors.NewVectorsClient(cfg)

	request := &vectors.GetVectorIndexRequest{
		Bucket:    oss.Ptr(bucketName),
		IndexName: oss.Ptr(indexName),
	}
	result, err := client.GetVectorIndex(context.TODO(), request)
	if err != nil {
		log.Fatalf("failed to get vector index %v", err)
	}
	log.Printf("get vector index result:%#v\n", result)
}

Referanslar

Tam örnek kod için bkz. get_vector_index.go.