Heim  >  Artikel  >  Datenbank  >  使用Oracle Text进行全文检索

使用Oracle Text进行全文检索

WBOY
WBOYOriginal
2016-06-07 16:55:37825Durchsuche

由于系统中数据不断增多,使得原用的like语法来进行查询法律全文变得十分缓慢,因此在原有系统中增加了全文检索的功能。

  由于系统中数据不断增多,使得原用的like语法来进行查询法律全文变得十分缓慢,因此在原有系统中增加了全文检索的功能。

  全文检索功能依赖于Oracle Text。首先保证Oracle Text组件在数据库中已安装。然后建立索引

  Sql代码

  --法律全文内容字段增加索引

  create index idx_flqw_nr on flqw(nr) indextype is ctxsys.context;

  --法律条款字段增加索引

  create index idx_fltk_nr on fltk(nr) indextype is ctxsys.context;

  由于Oracle Text使用的ctxsys.context类型索引不会自动维护,因些需要定时进行更新索引并进行索引优化,索引优化的次数要稍微少些。

  Sql代码

  --更新索引

  exec ctx_ddl.sync_index('idx_flqw_nr');

  exec ctx_ddl.sync_index('idx_fltk_nr');

  --优化索引

  exec ctx_ddl.optimize_index('idx_flqw_nr','full');

  exec ctx_ddl.optimize_index('idx_fltk_nr','full');

  也可以将更新索引及优化写成job,,这样可以定时运行,该job要与用户建立在同一个目录下。

  先创建相对应的存储过程。

  Sql代码

  --给flyy用户赋予在存储过程中执行全文索引的权限

  GRANT EXECUTE ANY PROCEDURE TO flyy;

  --更新索引的存储过程

  CREATE OR REPLACE PROCEDURE flyy.sync_index

  AS

  BEGIN

  ctxsys.ctx_ddl.sync_index ('idx_flqw_nr');

  ctxsys.ctx_ddl.sync_index ('idx_fltk_nr');

  END;

linux

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn