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