This topic describes how to use the GetVectorIndex operation in the OSS SDK for Java V2 to retrieve information about a specified vector index.
Permissions
An Alibaba Cloud account has full permissions by default. However, a RAM user or RAM role has no permissions by default. The Alibaba Cloud account owner or an administrator must use a RAM Policy or a Bucket Policy to grant the required permission.
API | Action | Description |
GetVectorIndex | oss:GetVectorIndex | Retrieves information about a vector index. |
Sample code
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.GetVectorIndexRequest;
import com.aliyun.sdk.service.oss2.vectors.models.GetVectorIndexResult;
public class GetVectorIndexSample {
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()) {
GetVectorIndexRequest request = GetVectorIndexRequest.newBuilder()
.bucket("examplebucket")
.indexName("exampleindex")
.build();
GetVectorIndexResult result = client.getVectorIndex(request);
System.out.printf("status code: %d, request id: %s%n", result.statusCode(), result.requestId());
}
}
}Related documentation
For the synchronous sample code, see GetVectorIndex.java.
For the asynchronous sample code, see GetVectorIndexAsync.java.
该文章对您有帮助吗?