ADD_FIELD_SECTION
Creates a field section and adds the section to an existing section group. This enables field section searching with the WITHIN operator. You can add an unlimited number of field sections.
Field sections are delimited by start and end tags. By default, the text within field sections are indexed as a sub-document separate from the rest of the document.
Unlike zone sections, field sections cannot nest or overlap. As such, field sections are best suited for non-repeating, non-overlapping sections such as TITLE and AUTHOR markup in e-mail- or news-type documents.
Because of how field sections are indexed, WITHIN queries on field sections are usually faster than WITHIN queries on zone sections.
Syntax
CTX_DDL.ADD_FIELD_SECTION(
group_name IN VARCHAR2,
section_name IN VARCHAR2,
tag IN VARCHAR2,
visible IN BOOLEAN default FALSE
);
group_name
Specify the name of the section group to which section_name is added. You can add an unlimited number of field sections to a single section group. Within the same group, section zone names and section field names cannot be the same.
section_name
Specify the name of the section to add to the group_name. Use this name to identify the section in queries. Avoid using names that contain non-alphanumeric characters such as _, because these characters must be escaped in queries. Section names are case-insensitive.
Note: The section_name may not be prefixed by the schema or the owner name as this syntax is not supported.
Within the same group, zone section names and field section names cannot be the same. The terms Paragraph and Sentence are reserved for special sections.
Section names need not be unique across tags. You can assign the same section name to more than one tag, which makes details transparent to searches.
tag
Specify the tag that marks the start of a section. For example, if the tag is <H1>, then specify H
- The start tag you specify must be unique within a section group.
Note: The tag may not be prefixed by the schema or the owner name as this syntax is not supported.
If group_name is an HTML_SECTION_GROUP, then you can create field sections for the META tag’s NAME/CONTENT attribute pairs. To do so, specify tag as meta@namevalue where namevalue is the value of the NAME attribute whose CONTENT attribute is to be indexed as a section. Refer to the example “Creating Sections for <META> Tags”.
Oracle Text knows what the end tags look like from the group_type parameter you specify when you create the section group.
visible
Specify TRUE to make the text visible within the rest of the document.
By default the visible flag is FALSE. This means that Oracle Text indexes the text within field sections as a sub-document separate from the rest of the document. However, you can set the visible flag to TRUE if you want text within the field section to be indexed as part of the enclosing document.
Examples
Visible and Invisible Field Sections
The following example defines a section group basicgroup of the BASIC_SECTION_GROUP type. (See “Section Group Types” for information about the BASIC_SECTION_GROUP type.) The example then creates a field section in basicgroup called Author for the <A> tag.
The example also sets the visible flag to FALSE:
begin
ctx_ddl.create_section_group('basicgroup', 'BASIC_SECTION_GROUP');
ctx_ddl.add_field_section('basicgroup', 'Author', 'A', FALSE);
end;
Because the Author field section is not visible, to find text within the Author section, you must use the WITHIN operator as follows:
'(Martin Luther King) WITHIN Author'
A query ofMartin Luther King without the WITHIN operator does not return instances of this term in field sections. To query text within field sections without specifying WITHIN, you must set the visible flag to TRUE when you create the section as follows:
begin
ctx_ddl.add_field_section('basicgroup', 'Author', 'A', TRUE);
end;
Creating Sections for <META> Tags
When you use the HTML_SECTION_GROUP, you can create sections for META tags.
Consider an HTML document that has a META tag as follows:
<META NAME="author" CONTENT="ken">
To create a field section that indexes the CONTENT attribute for the <META NAME="author"> tag:
begin
ctx_ddl.create_section_group('myhtmlgroup', 'HTML_SECTION_GROUP');
ctx_ddl.add_field_section('myhtmlgroup', 'author', 'META@AUTHOR');
end
After indexing with section group mygroup, query the document as follows:
'ken WITHIN author'
Limitations
Nested Sections
Field sections cannot be nested. For example, if you define a field section to start with <TITLE> and define another field section to start with <FOO>, the two sections cannot be nested as follows:
<TITLE> dog <FOO> cat </FOO> </TITLE>
To work with nested section define them as zone sections.
Repeated field sections are allowed, but WITHIN queries treat them as a single section. The following is an example of repeated field section in a document:
<TITLE> cat </TITLE>
<TITLE> dog </TITLE>
The query (dog and cat) within title returns the document, even though these words occur in different sections.
To have WITHIN queries distinguish repeated sections, define them as zone sections.
Related Topics
“WITHIN”