If you want to use SearchIndex by using an open source client, synchronize data in a wide table to an index table. To synchronize data in the wide table to the index table, create column mappings between the wide table and the index table. After you specify configuration items in a file that is used for mapping columns between the wide table and the index table, you can manage the column mapping relation between the tables. For example, you can create, query, add, or delete column mappings. This topic describes how to manage a column mapping relation.
Prerequisites
- Java Development Kit (JDK) 1.8 or later is installed.
- Your open source client is connected to SearchIndex, and configuration items in your file used for mapping columns between a wide table and an index table are specified. For more information, see Use an open source client to connect to and use SearchIndex.
Create column mappings
alter_external_index 'testTable', 'schema.json'
testTable
is the name of the wide table and schema.json
is the name of the configuration file used for mapping columns between the wide table
and the index table.
Modify a column mapping relation
alter_external_index 'testTable', 'new_schema.json'
new_schema.json
is the name of the modified configuration file that is used for mapping columns.
Query column mappings
describe_external_index 'testTable'
Add column mappings
add_external_index_field 'testTable', {FAMILY => 'f', QUALIFIER => 'money', TARGETFIELD => 'money_f', TYPE => 'FLOAT' }
alter_external_index
command is run. We recommend that you run the alter_external_index
command if you want to add a large number of column mappings.
Delete column mappings
remove_external_index 'testTable', 'f:name', 'f:age'
Delete all column mappings
References
If you want to use Java API operations to manage column mappings, call a Java API operation to connect to LindormTable. For more information, see Use the ApsaraDB for HBase API for Java to connect to and use the wide table engine LindormTable.
AliHBaseUETable
class. The following sample code provides examples:AliHBaseUETable table = (AliHBaseUETable)connection.getTable(TableName.valueOf("testTable"));
void addExternalIndex(ExternalIndexConfig config, List<ExternalIndexField> fields) throws IOException;
void removeExternalIndex(List<String> fields) throws IOException;