LindormTable provides a new search type named search indexes. This topic describes how to call the Apache HBase API and the Apache Solr API to connect to and use SearchIndex.

Background information

SearchIndex is integrated into LindormTable and LindormSearch to provide unified and easy-to-use API operations to meet various query requirements. LindormTable is compatible with the open source HBase API. LindormSearch is compatible with the Apache Solr API. You can execute Lindorm SQL statements to connect to and use search indexes. This is the standard method. You can also use an open source client to use search indexes. This method is convenient for more uses than the standard method.
Note If you execute a Lindorm SQL statement to create a table, execute SQL statements to use search indexes.

Prerequisites

  • Java Development Kit (JDK) 1.8 or later is installed.
  • The IP address of your client is added to the whitelist of your Lindorm instance. For more information, see Configure whitelists.

Procedure

  1. Enter the HBase shell. For more information, see Use HBaseue Shell to connect to and use LindormTable.
  2. In the HBase shell, create a wide table named testTable.
    create 'testTable', {NAME => 'f'}
  3. Create an index table named democollection. You can use one of the following methods to create an index table:
  4. Map columns in a wide table to columns in an index table. For example, map the f:name column in the testTable table to the name_s column in the democollection index table. In the f:name column, f specifies the column family name and name specifies the name of the column.
    1. In the bin directory of the file that is extracted from the HBase shell package, create a JSON file named schema. Copy the following sample code to the JSON file:
      {
        "sourceNamespace": "default",
        "sourceTable": "testTable",
        "targetIndexName": "democollection",
        "indexType": "SOLR",
        "rowkeyFormatterType": "STRING",
        "fields": [
          {
            "source": "f:name",
            "targetField": "name_s",
            "type": "STRING"
          }
        ]
      }
      Note For information about the parameters in the JSON file, see Configure column mapping.
    2. Enter the HBase shell and run the following command to configure column mappings between the wide table and the index table:
      alter_external_index 'testTable', 'schema.json'
      Note For information about how to manage column mappings between a wide table and an index table, see Manage a column mapping relation.
  5. Write a record to the testTable table. After column mappings between the wide table and the index table are configured, the data that is written to the wide table is automatically synchronized to the index table in real time. Historical data in a wide table can be synchronized only after you manually create a full index. For more information, see Create indexes for full data.
    put 'testTable', 'row1', 'f:name', 'foo'
  6. Query index data.
    1. Use the cluster management system of LindormSearch to query index data and obtain the primary key row1 of the wide table. For more information, see Query data. Obtain the primary key of the wide table
    2. Enter the HBase shell and run the following command to query data in the wide table:
      get 'testTable','row1'
      The following result is returned:
      COLUMN                                         CELL
       f:name                                        timestamp=1644462597661, value=foo
      1 row(s)
      Took 0.0942 seconds
  7. View the status of real-time data synchronization tasks on the Lindorm Tunnel Service (LTS) web UI. After column mappings between the wide table and the index table are configured, the data that is written to the wide table is automatically synchronized to the index table in real time.
    1. To log on to the LTS web UI, click the instance ID in the Lindorm console. In the left-side navigation pane, choose Wide Table Engine > SearchIndex. In the LTS WebUI Access section, click ClusterManager.
    2. In the left-side navigation pane, choose Lindorm Search > Real time replication to Solr.
      View the status of a task
      Note You can configure the latency metric for real-time data synchronization in the CloudMonitor console. The alert threshold for the maximum task latency can be set to 600,000 milliseconds. For more information, see Cloud service monitoring.