Oracle全文检索方面的研究(全8)

2014-11-24 08:12:02 · 作者: · 浏览: 3

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, oracle text

2 this is a oracle ctx_doc hightlight example.);

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