All Products
Search
Document Center

Tablestore:Query the description of a search index

Last Updated:Aug 02, 2024

After you create a search index, you can query the description of the search index, such as the field information and presorting settings.

API operation

You can call the DescribeSearchIndex operation to query the description of a search index.

Parameters

Parameter

Description

tableName

The name of the data table.

indexName

The name of the search index.

Methods

You can use the Tablestore console, Tablestore CLI, or Tablestore SDKs to query the description of a search index.

Before you query the description of a search index, make sure that the following preparations are made:

Use the Tablestore console

You can use the Tablestore console to query the description of a search index, such as the metering information and index fields.

  1. Go to the Indexes tab.

    1. Log on to the Tablestore console.

    2. In the top navigation bar, select a resource group and a region.

    3. On the Overview page, click the name of the instance that you want to manage or click Manage Instance in the Actions column of the instance.

    4. On the Tables tab of the Instance Details tab, click the name of the data table or click Indexes in the Actions column of the data table.

  2. On the Indexes tab, click Index Details in the Actions column of the search index that you want to manage.

  3. In the Index Details dialog box, view the metering information, routing key, index fields, and presorting settings of the search index.

Use the Tablestore CLI

You can run the describe_search_index command in the Tablestore CLI to query the description of a search index. For more information, see Search index.

The following sample code provides an example on how to query the description of a search index named search_index:

describe_search_index -n search_index

The following code shows a sample output. In the command output, the Index schema parameter indicates the schema of the search index and the TimeToLive parameter indicates the validity period of data in the search index.

Index schema:
{
    "IndexSetting": {
        "RoutingFields": null
    },
    "FieldSchemas": [
        {
            "FieldName": "id",
            "FieldType": "KEYWORD",
            "Index": true,
            "IndexOptions": null,
            "Analyzer": null,
            "AnalyzerParameter": null,
            "EnableSortAndAgg": true,
            "EnableHighlighting": null,
            "Store": false,
            "IsArray": false,
            "FieldSchemas": null,
            "IsVirtualField": false,
            "SourceFieldNames": null,
            "DateFormats": null
        },
        {
            "FieldName": "Col_Keyword",
            "FieldType": "KEYWORD",
            "Index": true,
            "IndexOptions": null,
            "Analyzer": null,
            "AnalyzerParameter": null,
            "EnableSortAndAgg": true,
            "EnableHighlighting": null,
            "Store": false,
            "IsArray": false,
            "FieldSchemas": null,
            "IsVirtualField": false,
            "SourceFieldNames": null,
            "DateFormats": null
        },
        {
            "FieldName": "Col_Long",
            "FieldType": "LONG",
            "Index": true,
            "IndexOptions": null,
            "Analyzer": null,
            "AnalyzerParameter": null,
            "EnableSortAndAgg": true,
            "EnableHighlighting": null,
            "Store": false,
            "IsArray": false,
            "FieldSchemas": null,
            "IsVirtualField": false,
            "SourceFieldNames": null,
            "DateFormats": null
        },
        {
            "FieldName": "Col_Text",
            "FieldType": "TEXT",
            "Index": true,
            "IndexOptions": null,
            "Analyzer": "single_word",
            "AnalyzerParameter": {
                "CaseSensitive": null,
                "DelimitWord": null
            },
            "EnableSortAndAgg": false,
            "EnableHighlighting": null,
            "Store": false,
            "IsArray": false,
            "FieldSchemas": null,
            "IsVirtualField": false,
            "SourceFieldNames": null,
            "DateFormats": null
        },
        {
            "FieldName": "Timestamp",
            "FieldType": "LONG",
            "Index": true,
            "IndexOptions": null,
            "Analyzer": null,
            "AnalyzerParameter": null,
            "EnableSortAndAgg": true,
            "EnableHighlighting": null,
            "Store": false,
            "IsArray": false,
            "FieldSchemas": null,
            "IsVirtualField": false,
            "SourceFieldNames": null,
            "DateFormats": null
        }
    ],
    "IndexSort": {
        "Sorters": [
            {
                "Name": "PrimaryKeySort",
                "Sorter": {
                    "Order": "ASC"
                }
            }
        ]
    }
}
TimeToLive: -1

Use Tablestore SDKs

You can query the description of a search index by using the following Tablestore SDKs: Tablestore SDK for Java, Tablestore SDK for Go, Tablestore SDK for Python, Tablestore SDK for Node.js, Tablestore SDK for .NET, and Tablestore SDK for PHP. In this example, Tablestore SDK for Java is used.

The following sample code provides an example on how to query the details of a search index, such as the time to live (TTL), creation time, synchronization status, and field information:

private static DescribeSearchIndexResponse describeSearchIndex(SyncClient client) {
    DescribeSearchIndexRequest request = new DescribeSearchIndexRequest();
    // Specify the name of the data table. 
    request.setTableName("<TABLE_NAME>"); 
    // Specify the name of the search index. 
    request.setIndexName("<INDEX_NAME>"); 
    DescribeSearchIndexResponse response = client.describeSearchIndex(request);
    // Display the details of the response. 
    System.out.println(response.jsonize()); 
    // Display the synchronization status of the data in the search index. 
    System.out.println(response.getSyncStat().getSyncPhase().name());
    return response;
}

References

If an existing search index no longer meets your requirements, you can create a new search index, modify the schema of the existing search index to add, delete, or modify index fields, or adjust the TTL configuration of the search index. For more information, see Create a search index, Dynamically modify the schema of a search index, and Specify the TTL of a search index.