【引用】Oracle全文检索方面的研究(全8)

3.9 Highlighting 高亮显示

并不是说将内容高亮显示,而是返回所有命中词在文档中的位置和命中词本身的长度。

这样用户在得到文档的同时,还得到了需要高亮显示的内容的长度和偏移量,真正的显示工作需要由用户来完成(原文:In Oracle Text query applications, you can present selected

documents with query terms highlighted for text queries or with themes highlighted for ABOUT

queries)

例子:

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, '<title>oracle text</title>

2 <body>this is a oracle ctx_doc hightlight example.</body>');

commit;

/

--建立索引

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

--返回结果的偏移量

set serverout on

declare

v_restab ctx_doc.highlight_tab;

begin

ctx_doc.highlight('ind_m_high', 1, 'oracle', v_restab, true);

for i in 1..v_restab.count loop

dbms_output.put_line('begin with: ' || v_restab(i).offset || ' length: ' || v_restab(i).length);

end loop;

end;

begin with: 11 length: 6

begin with: 36 length: 6

参考:

http://yangtingkun.itpub.net/post/468/212718

http://download.oracle.com/docs/cd/B19306_01/text.102/b14217/view.htm

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值