设为首页 加入收藏

TOP

Oracle全文检索方面的研究(全4)(一)
2014-11-24 08:12:01 来源: 作者: 【 】 浏览:0
Tags:Oracle 全文检索 面的 研究

3.4 Section Group 属性

Section group 支持查询包含内部结构的文档(如html、xml 文档等),可以指定对文档

的某一部分进行查询,你可以将查询范围限定在标题head 中。在html、xml 等类似结构的文

档中,除了用来显示的内容外,还包括了大量用于控制结构的标识,而这些标识可能是不希望被索引的,这就是section group 的一个主要功能(原文:In order to issue WITHIN queries on document sections, you must create a section group before you define your sections)

3.4.1 Null_section_group

系统默认,不进行任何节的过滤

例子:

Create table my_sec (id number, docs varchar2(100));

Insert into my_sec values (1, a simple section group, test null_section_group attribute.);

Insert into my_sec values (2, this record one, can be query in nornal);

Insert into my_sec values (4, this record

are tested for

the query in paragraph);

Commit;

/

--定义null_section_group

Create index ind_m_sec on my_sec(docs) indextype is ctxsys.context

parameters (section group ctxsys.null_section_group);

Select * from my_sec where contains(docs, record and query) > 0;

--要预先定义sentence 或paragraph,否则查询会出错

Select * from my_sec where contains(docs, (record and query) within sentence) > 0;

Begin

ctx_ddl.create_section_group(test_null, null_section_group);

ctx_ddl.add_special_section(test_null, sentence);

ctx_ddl.add_special_section(test_null, paragraph);

End;

drop index ind_m_sec;

Create index ind_m_sec on my_sec(docs) indextype is ctxsys.context

parameters (section group test_null);

Select * from my_sec where contains(docs, (record and query) within sentence) > 0;

Select * from my_sec where contains(docs, (record and query) within paragraph) > 0;

3.4.2 Basic_section_group

basic_section_group 才是支持节搜索的最基础的一种属性,但是它只支持以开头以

结尾的结构的文档

Create table my_sec1 (id number, docs varchar2(1000));

Insert into my_sec1 values (1, title

this is the contents of the example.

Use this example to test the basic_section_group.);

Insert into my_sec1 values (2, example

this line incluing the word title too.);

Commit;

/

Create index ind_my_sec1 on my_sec1(docs) indextype is ctxsys.context;

Select * from my_sec1 where contains (docs, heading) > 0;

--定义basic_section_group

Begin

Ctx_ddl.create_section_group(test_basic, basic_section_group);

End;

drop index ind_my_sec1;

Create index ind_my_sec1 on my_sec1(docs) indextype is ctxsys.context

parameters (section group test_basic);

Select * from my_sec1 where contains (docs, heading) > 0;

Select * from my_sec1 where contains (docs, context) > 0;

Select * from my_sec1 where contains (docs, use) > 0;

节搜索的另一个主要功能就是可以限制查询的范围,上面的文档包含了两部分,标题和正文,

其中标题使用标签,正文使用标签,我们可以对basic_section_group 添加

区域属性,运行查询在文档的某个范围内进行

Drop index ind_my_sec1;

Begin

ctx_ddl.add_zone_section(test_basic, head, heading);

End;

Create index ind_my_sec1 on my_sec1(docs) indextype is ctxsys.context

parameters (section group test_basic);

Select * from my_sec1 where contains (docs, title) > 0;

--在head 里面查询

Select * from my_sec1 where contains (docs, title within head) > 0;

3.4.3 Html_section_group

Html 文档具有很多不规范的表示方法,oracle 建议使用html_section_group 以便能够得到更

好的识别

--定义html_section_group

begin

ctx_ddl.create_section_group(htmgroup, HTML_SECTION_GROUP);

end;

create index myindex on docs(htmlfile) indextype is ctxsys.context

parameters(filter ctxsys.null_filter section group htmgroup);

无论是field_section 还是zone_section,表示文档的tag 标签都是大小写敏感的,其大小写需

要和原文中匹配

3.4.4.Xml_section_group

Xml 文档的格式要求比html 文档严谨、规范, 这也使得xml_section_group 比

html_section_group 具有了更多的功能

例子:

Create table m

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Oracle全文检索方面的研究(全1) 下一篇Oracle全文检索方面的研究(全6)

评论

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

·我的Linux内核学习笔 (2025-12-26 22:21:10)
·如何评价腾讯开源的 (2025-12-26 22:21:07)
·为什么TCP网络编程中 (2025-12-26 22:21:04)
·Python 数据分析与可 (2025-12-26 21:51:20)
·从零开始学Python之 (2025-12-26 21:51:17)