Download the latest version of HBase Shell. Configure HBase Shell based on the usage instructions, and configure a whitelist for the HBase cluster.

Create a table in an HBase cluster

hbase(main):002:0> create 'testTable', {NAME => 'f'}

The preceding command is used to create a table in HBase. The name of the table to be created is testTable and the column family is f.

Create an index in a Search instance

On the details page of the Search instance, click Database Connection and find the Access a Web UI section. Note: Before you access the web console, you must configure a whitelist and set a password.Cluster
Set the config set parameter to _indexer_default as the configuration set, set the numShards parameter to the number of nodes, and retain the default values for other parameters, as shown in the following figure.Collection

Create mappings

For example, assume that you need to map the f:name column in the testTable table to the name_s column in the democollection collection. For the f:name column, f is the column family and name is the name of the column. You can write the following data in the JavaScript Object Notation (JSON) format to a file named schema.json:

{
  "sourceNamespace": "default",
  "sourceTable": "testTable",
  "targetIndexName": "democollection",
  "indexType": "SOLR",
  "rowkeyFormatterType": "STRING",
  "fields": [
    {
      "source": "f:name",
      "targetField": "name_s",
      "type": "STRING"
    }
  ]
}

Note: For more information about the parameters in the preceding JSON string, see Manage HBase full-text indexes.

Run the following command in HBase Shell:

hbase(main):006:0> alter_external_index 'testTable', 'schema.json'

After the command is run, the mapping between the source column and the destination column is created.

Write data to HBase

The following HBase Shell command is used to write a sample data record to HBase.

hbase(main):008:0> put 'testTable', 'row1', 'f:name', 'foo'
Took 0.1697 seconds

Query data in a Search instance

In the web console of the Search service, select the index democollection that you created and click Query to query the sample data record.Execute Query

Query original data in an HBase table

Generally, the Search service is used to synchronize specific columns in an HBase table to a Search instance. This means that only columns that require multi-dimensional queries are written to the mapping file in the JSON format. In the query result, data in each row contains the ID column, which is the rowkey of the row in the HBase table. After you obtain the rowkey, you can query the complete data in the HBase table.