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
A Tablestore client is initialized. For more information, see Initialize a Tablestore client.
Usage notes
The SQL query feature is supported by Tablestore SDK for PHP V5.1.0 and later. When you use the SQL query feature, make sure that a supported version of Tablestore SDK for PHP is installed.
For information about the version history of Tablestore SDK for PHP, see Version history of Tablestore SDK for PHP.
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 TABLEstatement 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.