db2全文检索

来源:互联网 发布:多空线dkx指标优化 编辑:程序博客网 时间:2024/05/01 04:58
 

DB2Text Information Extender is one of a family of DB2 Extenders. Itenables programmers to include SQL queries for text documents in theirapplications. Other Extenders can search images, or handle XMLdocuments and spatial data.

文件 地址 http://blog.itpub.net/resource/901/657


DB2 TIE是独立于DB2的一个单独的产品,但其使用必须依赖DB2,对运行环境要求如下:

l         Windows NT Version 4.0 with Service Pack 5, or higher

l         Windows 2000

l         RISC System/6000 and AIX Version 4.2 or higher

l         Solaris Version 2.6 or higher

l         DB2 Version 7.2

Windows平台下的步骤如下:

1. Use the setup.exe to transfer the files from the package to the target machine.

2. Reboot the system after data transfer.

3. Call db2text start to start the DB2 Text Information Extender update and locking services.

4. To deinstall the product use the Add/Remove Programs icon in the Control Panel.

5. 如果需要从对象文件中进行全文检索,还需安装DataLink jarctedludf.jar: In the db2 command line processor execute the following command: call sqlj.install_jar('file:////sqllib/java/ctedludf.jar','ctedludf_jar') (注:execute sqlj.remove_jar('ctedludf_jar') to unregisters the jar file. It can be used in both environments.)

以下创建过程假设以db2admin用户执行,操作在本地itsowsad数据库实例上进行。

1.       在“服务”中修改登录身份,确保以db2admin而不是本地系统用户运行DB2EXT-DB服务。启动TIE服务(或者执行:db2text start.

2.       Control Center中以administrator身份连接,为db2admin用户授权(DatabaseSchema权限)

3.       启动DB2实例的全文检索支持。在命令窗口中,执行 db2text enable database for text connect to itsowsad user db2admin using dam。返回成功提示“CTE0001 操作成功完成。”

4.       创建全文索引。

a)         建表:db2 create table sample (name varchar(60) primary key not null,description varchar(400))

b)        插入数据:db2 insert into sample values ('First row','This product comes from IBM') db2 insert into sample values ('Second row','and is named DB2 Text Information Extender')

c)        建索引:db2text CREATE INDEX sample_inx ON sample (description) FOR TEXT connect to itsowsad user db2admin using dam,返回“CTE0001 操作成功完成。”

5.       更新索引(增量索引):db2text update INDEX sample_inx FOR TEXT connect to itsowsad user db2admin using dam,返回“CTE0001 操作成功完成。”

6.       检查索引状态:db2 SELECT indexname, number_docs FROM db2ext.textcolumns

7.       执行查询:db2 SELECT description FROM sample WHERE CONTAINS (description,'"IBM"') = 1

原创粉丝点击