设为首页 加入收藏

TOP

Oracle全文检索方面的研究(全10)(二)
2014-11-24 08:09:26 来源: 作者: 【 】 浏览:6
Tags:Oracle 全文检索 面的 研究

insert into mytable3 values(111559,2.txt);

insert into mytable3 values(111560,2.doc);

insert into mytable3 values(111561,2.xls);

insert into mytable3 values(111562,2.pdf);

commit;

--先删除引用

begin

ctx_ddl.drop_preference(COMMON_DIR);

end;

--建立 file datastore

begin

ctx_ddl.create_preference(COMMON_DIR,FILE_DATASTORE);

ctx_ddl.set_attribute(COMMON_DIR,PATH,D:search);

end;

--先删除索引

drop index myindex3;

--建立索引,8个文件,内容简单,耗时1.5s

create index myindex3 on mytable3(docs) indextype is ctxsys.context parameters (datastore COMMON_DIR lexer foo.my_chinese_lexer);

select * from mytable3 where contains(docs,text)>0; --查询,支持txt

select * from mytable3 where contains(docs,pdf)>0; --查询,支持pdf

select * from mytable3 where contains(docs,excel)>0; --查询,支持excel

select * from mytable3 where contains(docs,word)>0; --查询,支持doc

select * from mytable3 where contains(docs,文本)>0; --查询,支持中文

select * from mytable3 where contains(docs,文档)>0; --查询,支持中文

select * from mytable3 where contains(docs,阅读)>0; --查询,支持中文pdf

select * from mytable3 where contains(docs,这是Excel)>0; --查询,支持中文

--暂时测试支持doc,txt,xls,pdf

--更新了文件内容2.txt

select * from mytable3 where contains(docs,这个测试用的文本)>0; --查询无更新好数据

--不同步索引,无效

--同步更新索引

Begin

Ctx_ddl.sync_index(myindex3);

End;

--再次查询

select * from mytable3 where contains(docs,测试)>0; --还是无效

--用相同的值取代2.txt然后再同步索引

Update mytable3 set docs=2.txt where id=111559;

--再同步索引

--同步更新索引

Begin

Ctx_ddl.sync_index(myindex3);

End;

--再次查询

select * from mytable3 where contains(docs,测试)>0; --结果出现,可见,单更新文件内容,同步索引是无效的,索引认的是数据库纪录,数据库纪录改变,索引才会更新

--新增加文件,结果雷同。关键是要更新数据库纪录,即使改了文件内容,也要用相同的值update数据库纪录一次。

4.3 检索结果高亮显示

Create table my_high (id number primary key, docs varchar2(1000));

insert into my_high values (1, this is a oracle text example. And oracle is the key word.);

insert into my_high values (2, oracle textthis is a oracle ctx_doc hightlight example.);

commit;

/

--建立索引

create index ind_m_high on my_high(docs) indextype is ctxsys.context;

--返回结果的偏移量

set serverout on

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Oracle下SQL基本操作(二) 下一篇Oracle存储过程返回游标,查询语..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·SOLVED: Ubuntu 24.0 (2025-12-26 22:51:53)
·Linux 常用命令最全 (2025-12-26 22:51:50)
·新人如何从零开始学 (2025-12-26 22:51:47)
·我的Linux内核学习笔 (2025-12-26 22:21:10)
·如何评价腾讯开源的 (2025-12-26 22:21:07)