Sample: Creating N-gram and morphological indexes for rich
text and proprietary formats
About this task
Use the following instructions to setup and synchronize Db2® Text Search indexes
for morphological and N-gram indexing in the SAMPLE database. Search for meaningless Chinese
words.
Procedure
Create two tables for morphological and N-gram indexing.
The tables contain columns k and b, where column k is the primary
key, and column b will have rich text data.
db2 "create table richtext_morpho(
k varchar(50)not null,
b blob (1G),
primary key(k)
)"
db2 "create table richtext_ngram(
k varchar(50)not null,
b blob (1G),
primary key(k)
)"
Issue the CREATE INDEX command to create
a text search index on column b of table RICHTEXT_MORPHO. The name
of the text search index is MORPHOINDEX.
db2ts " CREATE INDEX db2ts.morphoindex FOR TEXT
ON richtext_morpho (b) LANGUAGE zh_CN FORMAT INSO
INDEX CONFIGURATION (CJKSEGMENTATION 'morphological')
CONNECT TO sample";
Issue the CREATE INDEX command to create a text search index on column
b of table RICHTEXT_NGRAM. The name of the text search index is NGRAMINDEX.
db2ts " CREATE INDEX db2ts.ngramindex FOR TEXT
ON richtext_ngram (b) LANGUAGE zh_CN FORMAT INSO
INDEX CONFIGURATION (CJKSEGMENTATION 'ngram')
CONNECT TO sample";
Load data into the two tables.
db2 "import from ./data/cjk_richtext.del of DEL lobs from ./data/
replace into richtext_morpho ";
db2 "import from ./data/ cjk_richtext.del of DEL lobs from ./data/
replace into richtext_ngram ";