The db2ts CREATE INDEX command creates a text search index for a text column. You can then search the column data by using text search functions.
The text search index does not contain any data until you run the text search UPDATE INDEX command, or the DB2® Administrative Task Scheduler runs the UPDATE INDEX command according to the defined update frequency for the index.
For execution, you must prefix the command with db2ts at the command line.
To schedule automatic index updates, the instance owner must have DBADM authority or CONTROL privileges on the administrative task scheduler tables.
Database
>>-CREATE INDEX--index-name--FOR TEXT---------------------------> >--ON--schema-name--table-name----------------------------------> >--+-(--text-column-name--)----------------------+--------------> '-(--function-name--(--text-column-name--)--)-' >--| text default information |--| update characteristics |-----> >--| storage options |--| index configuration options |---------> >--| partition options |--| connection options |--------------->< text default information |--+---------------------+--+------------------+----------------> '-CODEPAGE--code-page-' '-LANGUAGE--locale-' >--+----------------+-------------------------------------------| '-FORMAT--format-' update characteristics |--+--------------------------------------------+---------------> '-UPDATE FREQUENCY--+-NONE-----------------+-' '-| update frequency |-' >--| incremental update characteristics |-----------------------| update frequency |--D-(-+-*------------+-)--H-(-+-*------------+-)---------------> | .-,--------. | | .-,--------. | | V | | | V | | '---integer1-+-' '---integer2-+-' .-,--------. V | >--M-(---integer3-+-)-------------------------------------------| incremental update characteristics |--+----------------------------+-------------------------------| '-UPDATE MINIMUM--minchanges-' storage options |--+---------------------------------+--------------------------> '-COLLECTION DIRECTORY--directory-' >--+-------------------------------------------+----------------| '-ADMINISTRATION TABLES IN--tablespace-name-' index configuration options |--+-----------------------------------------------+------------| | .-,----------------. | | V | | '-INDEX CONFIGURATION--(---| option-value |-+-)-' option-value |--+----------------------------------------------+-------------| +-COMMENT--text -------------------------------+ +-UPDATEAUTOCOMMIT--+-+--------------------+-+-+ | | '-commitcount_number-' | | | '-+------------+---------' | | '-commitsize-' | +-COMMITTYPE--committype-----------------------+ +-COMMITCYCLES--commitcycles-------------------+ +-INITIALMODE--initialmode---------------------+ +-LOGTYPE--ltype-------------------------------+ +-AUXLOG--auxlog_value-------------------------+ '-CJKSEGMENTATION -cjksegmentation-method------' connection options |--+----------------------------------------------------------------+--| '-CONNECT TO--database-name--+---------------------------------+-' '-USER--username--USING--password-'
The default frequency value is taken from the view SYSIBMTS.TSDEFAULTS, where DEFAULTNAME='UPDATEFREQUENCY'.
The COLLECTION DIRECTORY parameter is supported only for an integrated text search server setup. Review the usage notes for additional information about collection locations.
For a nonpartitioned database, if you do not specify a table space, the table space of the base table for which you are creating the index is used.
For a partitioned database, you must use the ADMINISTRATION TABLES parameter explicitly when text indexes are created. The table space must be in the same partition group as the table space of the base table to ensure that the staging tables for the text search index are distributed in the same manner as the corresponding base table.
Option | Value | Data type | Description |
---|---|---|---|
COMMENT | text | String value less than 512 bytes | Adds a string comment value to the REMARKS column in the DB2 Text Search catalog view TSINDEXES. It also adds the string comment value as the description of the collection. |
UPDATEAUTOCOMMIT | commitsize | - |
|
COMMITTYPE | committype | String | Starting in DB2 Version 10.1 Fix Pack 3 and later fix packs, specifies rows or hours for the UPDATEAUTOCOMMIT index configuration option. The default is rows. |
COMMITCYCLES | commitcycles | Integer | Starting in DB2 Version 10.1 Fix Pack 3 and later fix packs, specifies the number of commit cycles. The default is 0 for unlimited cycles. If cycles are not explicitly specified, the update operation uses as many cycles as required based on the batch size that is specified with the UPDATEAUTOCOMMIT option to finish the update processing. You can use this option with the UPDATEAUTOCOMMIT setting with a committype. |
INITIALMODE | initialmode | String | Starting in DB2 Version
10.1 Fix Pack 3 and later fix packs, specifies how the updates are
processed. The INITIALMODE index configuration
option has three possible values:
|
LOGTYPE | ltype | String | Starting in DB2 Version
10.1 Fix Pack 3 and later fix packs, specifies whether triggers are
added to populate the primary log table. It has two values:
|
AUXLOG | auxlog_value | String | Controls the creation of the additional log infrastructure to capture changes that are not recognized by a trigger. The default setting for range partitioned tables is ON, otherwise it is OFF. You can change the default value in the default table with a setting for AuxLogNorm for nonrange-partitioned tables and AuxLogPart for range-partitioned tables. |
CJKSEGMENTATION | CJKSEGMENTATION_method | String value less than 512 bytes | Specifies the segmentation method for documents
in Chinese, Japanese, and Korean languages (zh_CN, zh_TW, ja_JP, ko_KR
locale sets), including such documents when automatic language detection
is enabled (LANGUAGE AUTO). If no option is specified, the value for CJKSEGMENTATION in
the defaults table is applied. Supported values are:
The specified segmentation method is added to the SYSIBMTS. TSCONFIGURATION administrative view and cannot be changed after the text index is created. |
[A-Za-z][A-Za-z0-9@#$_]*
or"[A-Za-z ][A-Za-z0-9@#$_ ]*"
tigertail_MYTSDB_TS250517_0000
You
can retrieve the collection name from the SYSIBMTS.TSCOLLECTIONNAMES
view (column COLLECTIONNAME). You cannot change the auxiliary log property for a text index after the index is created.
The AUXLOG option is supported for nicknames for data columns that support an MQT with deferred refresh. It is not supported for views.
You can specify the UPDATEAUTOCOMMIT index configuration option without type and cycles for compatibility with an earlier version. It is associated by default with the COMMITTYPE rows option and unrestricted cycles.
The UPDATEAUTOCOMMIT, COMMITTYPE, and COMMITSIZE index configuration options are also specified for an UPDATE INDEX operation to override the configured values. Values that you submit for a specific update are applied only once and not persisted.
With theINITIALMODE SKIP option, the text search index manager is responsible to populate the index appropriately. This option allows control of the sequence in which data from the text table will initially be processed.
The CJKSEGMENTATION option applies to zh_CN, zh_TW, ja_JP and ko_KR locale sets for Chinese, Japanese, and Korean languages. The MORPHOLOGICAL or NGRAM option that is specified for the segmentation method is added to the SYSIBMTS.TSCONFIGURATION administration view.
Creating an index with the LANGUAGE parameter set to the AUTO option allows CJKSEGMENTATION specification as an option. The specified segmentation method applies to Chinese, Japanese, and Korean language documents. You cannot change the value that is set for the CJKSEGMENTATION_method value after index creation is complete.
select bookname from ngrambooks where contains (story, '军书','QUERYLANGUAGE=zh_CN') = 1
If you use the INITIALMODE SKIP option, combined with the LOGTYPE ON and AUXLOG ON options, you must manually insert the log entries into the staging table, but only for the initial update. All subsequent updates are handled automatically.