You need to enable JavaScript to run this app.
Torch Object Storage

Torch Object Storage

Copy page
Download PDF
Vector index
DeleteIndex(TOS Vectors Java SDK)
Copy page
Download PDF
DeleteIndex(TOS Vectors Java SDK)
The deleteIndex interface deletes a specified vector index. This article explains how to delete an index using the deleteIndex interface of TOS Vectors Java SDK.​
Notes​
  • To prevent key leakage, the sample code reads the Access Key ID and Secret Access Key from environment variables. Therefore, before using the SDK, configure long-term access credentials. For details, see Configure Long-term Access Credentials.​
  • TOS Vectors Java SDK supports using temporary credentials; it also supports configuring timeout, retry policies, and other mechanisms. You can flexibly set these based on your business needs to enhance application security. For details, see Common Configuration Scenarios.​
Permissions required​
The main account has all permissions by default, but the IAM user has no permissions by default. If you need to perform the deleteIndex operation with a sub-account, the main account must grant the following permissions to the sub-account through IAM policies and bucket policies:​
tosvectors:DeleteIndex​
Code example​
Delete the specified vector index​
​
// Delete the specified vector index.​
import com.volcengine.tos.TOSVectorsClientBuilder;​
import com.volcengine.tos.TOSVectors;​
import com.volcengine.tos.TosClientException;​
import com.volcengine.tos.TosServerException;​
import com.volcengine.tos.model.vectors.DeleteIndexInput;​
import com.volcengine.tos.model.vectors.DeleteIndexOutput;​
​
public class DeleteIndexExample {​
public static void main(String[] args) {​
String endpoint = 'Provide your endpoint';​
String region = 'Provide your region';​
String accessKey = System.getenv("TOS_ACCESS_KEY");​
String secretKey = System.getenv("TOS_SECRET_KEY");​
String accountID = System.getenv("TOS_ACCOUNT_ID");​
​
// Fill in the vector bucket name and index name.​
String vectorBucketName = 'Provide your vector bucket name';​
String indexName = "test";​
​
// Initialize client.​
TOSVectors client = new TOSVectorsClientBuilder().build(region, endpoint, accessKey, secretKey);​
​
try {​
// Create a delete index request.​
DeleteIndexInput input = DeleteIndexInput.builder()​
.vectorBucketName(vectorBucketName) // Vector bucket name​
.accountId(accountID) // Account ID​
.indexName(indexName) // Index name​
.build();​
​
// Call the delete index interface.​
DeleteIndexOutput output = client.deleteIndex(input);​
​
System.out.println("Delete index successfully");​
System.out.println("RequestID: " + output.getRequestInfo().getRequestId());​
System.out.println("StatusCode: " + output.getRequestInfo().getStatusCode());​
​
} catch (TosClientException e) {​
// Operation failed, caught a Client exception. Generally, it is due to incorrect request parameters, and in this case, the request was not sent.​
System.out.println("Operation failed");​
System.out.println("Message: " + e.getMessage());​
if (e.getCause() != null) {​
e.getCause().printStackTrace();​
}​
} catch (TosServerException e) {​
// Operation failed, server exception captured, and detailed error information returned from the server can be obtained.​
System.out.println("Operation failed");​
System.out.println("StatusCode: " + e.getStatusCode());​
System.out.println("Code: " + e.getCode());​
System.out.println("Message: " + e.getMessage());​
System.out.println("RequestID: " + e.getRequestID());​
} catch (Throwable t) {​
// As a fallback to catch other exceptions, it generally won't execute here.​
System.out.println("Operation failed");​
System.out.println("unexpected exception, message: " + t.getMessage());​
}​
}​
}​
​
Related documentation​
For the API documentation of DeleteIndex, see DeleteIndex.​
Last updated: 2026.02.06 18:01:48