You can execute the show index statement to query the index information about a table, such the index name, index fields, and index type.
For more information about the show index statement, see Query the index information about a table.
Prerequisites
An OTSClient instance is initialized. For more information, see Initialize an OTSClient instance.
A mapping table is created. For more information, see Create mapping tables.
Usage notes
Tablestore SDK for PHP V5.1.0 or later supports the SQL query feature. Before you use the SQL query feature, make sure that Tablestore SDK for PHP V5.1.0 or later is obtained. For information about the versions of Tablestore SDK for PHP, see Version history of Tablestore SDK for PHP.
Parameters
Parameter | Description |
query | The SQL statement. Configure the parameter based on the required feature. |
Examples
The following sample code provides an example on how to execute the SHOW INDEX IN `tableName`;
statement to query the index information about a table named tableName:
$request = array(
'query' => 'SHOW INDEX IN `tableName`;',
);
$response = $otsClient->sqlQuery ($request);
$sqlRows = $response['sql_rows'];
print json_encode($sqlRows, JSON_PRETTY_PRINT);
References
If you want to use a specific search index to query data when you use the SQL query feature, you can execute the
CREATE TABLE
statement to create a mapping table for the search index. For more information, see Create mapping tables for search indexes.You can execute SQL statements to query data based on the fields of an index. For more information, see Query data.