All Products
Search
Document Center

Lindorm:Use Lindorm-cli to manage search indexes

Last Updated:May 13, 2025

Lindorm supports search indexes for wide tables. After you create a search index and configure mapping, data written to a wide table is automatically synchronized to LindormSearch. You can call the Elasticsearch API to perform queries. This topic describes how to use Lindorm-cli to manage search indexes and perform real-time queries on structured data.

Prerequisites

Step 1: Map data types of wide table columns

  1. Use Lindorm-cli to connect to and use LindormTable.

  2. Use Lindorm-cli to map data types of wide table columns to ensure that data written to the wide table can be parsed in the correct format and synchronized to the search index. In this example, the Rowkey and f1:name columns of the wide table are mapped as HSTRING type.

    ALTER TABLE testTable MAP DYNAMIC COLUMN`ROW` HSTRING, f1:name HSTRING;

    For more information, see data type mappings.

    Note
    • To make the Rowkey (the ROW field in the preceding code) stored in the wide table consistent with the primary key ID stored in LindormSearch, you need to map the Rowkey data type as HSTRING before creating the index.

    • Otherwise, the Rowkey of the wide table is mapped to the primary key of the search index table in HEX encoding format. For more information, see parameter description of rowkeyFormatterType.

Step 2: Create a search index

Create a search index named idx in Lindorm-cli.

CREATE INDEX idx USING SEARCH ON testTable (f1:name);

By default, raw data is not stored in the search index. To directly access the raw data of the index columns in the search index table, you can specify the SOURCE_SETTINGS attribute when you create the index.

CREATE INDEX idx USING SEARCH ON testTable(f1:name) WITH (SOURCE_SETTINGS='
{
  "enabled": true
}
');
Note
  • After the created search index becomes ACTIVE, data written to the wide table is automatically synchronized to the index table in real time. For information about how to view the index status, see SHOW INDEX. To synchronize historical data in the wide table, you need to execute the ALTER INDEX statement to rebuild indexes. Example: ALTER INDEX idx ON testTable REBUILD;, where idx indicates the index name of the wide table search index.

  • To disconnect from Lindorm-cli, run the exit, quit, or ctrl+d command. For more Lindorm-cli commands, see Common commands used in Lindorm-cli.

Step 3: Write data to the wide table

  1. Use Lindorm Shell to connect to LindormTable.

  2. In Lindorm Shell, call the HBase API to insert a data record into the table testTable.

    put 'testTable', 'row1', 'f1:name', 'foo'

Step 4: Use search indexes to query data

  1. Query index data.

    Log on to the LindormSearch GUI. Call the Elasticsearch API to query index data and obtain the primary key ID of the search index table.

    Note
    • The name of the LindormSearch index table is concatenated in the format of <Namespace name>.<Table name>.<Index name>.

    • The column names in a search index table are concatenated based on the following rules:

      • When the column family of the wide table is f, the column name in the wide table and index table is the same. For example, f:name corresponds to name.

      • When the column family of the wide table is not f, the column name in the index table is in the format of <Column family name>_<Column name>. For example, f1:name corresponds to f1_name.

    GET /default.testTable.idx/_search
    {
      "size": 10,
      "query": {
        "match": {
          "f1_name": "foo"
        }
      }
    }

    The following results are returned:

    {
      "took": 8,
      "timed_out": false,
      "_shards": {
        "total": 4,
        "successful": 4,
        "skipped": 0,
        "failed": 0
      },
      "hits": {
        "total": {
          "value": 1,
          "relation": "eq"
        },
        "max_score": 0.2876821,
        "hits": [
          {
            "_index": "default.testTable.idx",
            "_id": "row1",
            "_score": 0.2876821,
            "_source": {
              "_searchindex_id": "row1",
              "update_version_l": 1745389294641,
              "f1_name": "foo"
            }
          }
        ]
      }
    }

    Obtain the primary key ID (_id) of the search index table from the results.

  2. Run the following command in Lindorm Shell to query wide table data:

    get 'testTable','row1'

    The following results are returned:

    COLUMN                                                     CELL                                                                                                                                                                      
     f1:name                                                   timestamp=1745389294641, value=foo                                                                                                                                        
    1 row(s)