You can call the DeleteSearchIndex operation to delete a search index that is created for a data table.
Prerequisites
- The OTSClient 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 search indexes.
Parameters
Parameter | Description |
tableName | The name of the data table. |
indexName | The name of the search index. |
Sample code
The following sample code provides an example on how to delete a search index that is created for the specified data table:
private static void deleteSearchIndex(SyncClient client) {
DeleteSearchIndexRequest request = new DeleteSearchIndexRequest();
// Specify the name of the data table.
request.setTableName("<TABLE_NAME>");
// Specify the name of the search index.
request.setIndexName("<INDEX_NAME>");
// Call the client to delete the search index.
client.deleteSearchIndex(request);
}
References
Tablestore also provides other methods to query data, such as secondary indexes, SQL statements, and data queries by primary key. If you no longer use search indexes, you can use secondary indexes, SQL statements, and primary key-based methods to query data. For more information, see Secondary Index, Query data in tables, and Read data.