日期:2014-05-16  浏览次数:20490 次

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

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 才是支持节搜索的最基础的一种属性,但是它只支持以<tag>开头以

</tag>结尾的结构的文档

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

Insert into my_sec1 values (1, '<heading>title</heading>

<context>this is the contents of the example.

Use this example to test the basic_section_group.</context>');

Insert into my_sec1 values (2, '<heading>example</heading>

<context>this line incluing the word title too.</context>');

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;