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