You can call the DeleteSearchIndex operation to delete a search index that is created for a data table.
Prerequisites
- The TableStoreClient is initialized. For more information, see Initialize an OTSClient instance.
- A data table is created. Data is written to the table.
- A search index is created for the data table. For more information, see Create a search index.
Usage notes
A deleted search index cannot be recovered. Proceed with caution.
Parameters
Parameter | Description |
TableName | The name of the data table. |
IndexName | The name of the search index. |
Examples
The following sample code provides an example on how to delete a search index:
func DeleteSearchIndex(client *tablestore.TableStoreClient, tableName string, indexName string) {
request := &tablestore.DeleteSearchIndexRequest{}
request.TableName = tableName // Specify the name of the data table.
request.IndexName = indexName // Specify the name of the search index.
resp, err := client.DeleteSearchIndex(request) // Delete the search index.
if err != nil {
fmt.Println("error: ", err)
return
}
fmt.Println("DeleteSearchIndex finished, requestId: ", resp.ResponseInfo.RequestId)
}
References
If existing search indexes do not meet your business requirements, you can create search indexes or modify the schemas of existing search indexes to add, remove, and modify index columns. For more information, see Create a search index and Dynamically modify the schema of a search index.