Get vector index information (Java SDK V2)
You can call 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. RAM users and RAM roles have no permissions by default. The account owner or an administrator must grant permissions by using a RAM Policy or Bucket Policy.
|
API |
Action |
Description |
|
GetVectorIndex |
oss:GetVectorIndex |
Retrieves information about a vector index. |
Prerequisites
To run the sample code, add the OSS Java SDK V2 dependency to the pom.xml file of your project:
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>alibabacloud-oss-v2</artifactId>
<version>LATEST_VERSION</version>
</dependency>
The Maven groupId is com.aliyun. Do not confuse it with the Java package path com.aliyun.sdk.service.oss2 used in the import statements — the package path and the Maven coordinates are different.
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.