Section Types: Zone and Field

Zone sections are like sections from the previous release of interMedia Text (called ConText). interMedia Text records where in the document the section start and end tags occur. WITHIN queries check that the words occur between the start and end word offset.

If a zone section repeats, each instance is treated separately in query semantics. Zone sections can enclose other sections, including themselves, and can be enclosed by other sections. With the interMedia Text API, a zone section is added by a procedure in the following format:

ctx_ddl.add_zone_section('groupname', 'sectionname', 'tag');

Field sections, on the other hand, extract their contents and index them separately from other words in the document. WITHIN queries are run on this separate, smaller index. This makes field section query faster than zone section query, especially when the section tags occur in every document.

However, this speed comes at the cost of flexibility. Field sections are meant for non-repeating, non-overlapping sections. If a field section repeats, it is treated as a continuation of the section, not a distinct instance. If a field section is overlapped by itself or by another field section, it is implicitly closed at the point where the other section starts. Also, there is a maximum of 64 field sections in any section group. (This is 64 section names, not tags -- you can map multiple tags to the same section name.) With the interMedia Text API, a field section is added by a procedure in the following format:

ctx_ddl.add_field_section('groupname', 'sectionname', 'tag');

Several examples can illustrate the different types of sections and the impact on query semantics. The examples use the following three-line document:

<A>rat</A><A>ox</A>

<B>tiger rabbit</B>

<C>dragon<C>snake</C></C>

Note: This is an XML-style markup, but without a DTD, so the basic section group type is used:

ctx_ddl.create_section_group('mygroup','basic_section_group');

Now, create the zone sections:

ctx_ddl.add_zone_section('mygroup', 'asec', 'a');

ctx_ddl.add_zone_section('mygroup', 'bsec', 'b');

ctx_ddl.add_zone_section('mygroup', 'csec', 'c');

These procedures tell the section group to recognize A tags as the section ASEC, B tags as the section BSEC, and C tags as the section CSEC. To perform section queries, use the WITHIN operator. (Remember to use the section name and not the tag.) Consider these two examples:

contains(text, 'rat within asec') > 0

contains(text, 'tiger within asec') > 0

The first query finds the document, but the second query does not, because although the document contains "tiger", the term does not occur in the ASEC. However, both queries would find the document if the original setup had mapped A and B to the same section name (ASEC), as follows:

ctx_ddl.add_section('mygroup', 'asec', 'a');

ctx_ddl.add_section('mygroup', 'asec', 'b');

Zone Query Semantics

An important aspect of zone section query semantics is that each instance is treated distinctly. That is, a query like this:

contains(text, '(tiger and rabbit) within bsec') > 0

does find the document, but a query like this:

contains(text, '(rat and ox) within asec') > 0

does not find the document. Although the document has "rat" and has "ox", and "rat" is in ASEC and "ox" is in ASEC, "rat" and "ox" are not within the same ASEC. Note, however, that:

contains(text, '(dragon and snake) within csec') > 0

does find the document, because they are both in the outer CSEC, even though the inner CSEC contains only "snake".

Field Query Semantics

To illustrate field query semantics, assume that ASEC had been made a field section instead of a zone section, as follows:

ctx_ddl.add_field_section('mygroup', 'asec', 'a');

Unlike zone sections, each instance of a field section is considered a continuation of the section. The following query:

contains(text, '(rat and ox) within asec') > 0

does find the document, although it did not find the document when ASEC was a zone section. The field section simply considers the two instances together. Field sections work best on sections like BSEC, which does not repeat like ASEC or nest like CSEC.

Another subtle aspect of field sections is as follows. If ASEC is a zone section, then the following query:

contains(text, 'rat') > 0

does find the document, because it contains the word "rat". However, remember that field sections work by extracting the document contents and indexing them separately. Thus, if ASEC were a field section, this query would not find the document because "rat" is in ASEC, which is separate from the document contents.

You can, however, change this by making the field section visible. There is an optional boolean fourth argument to the add_field_section procedure. If this boolean argument is set to TRUE, as in the following:

ctx_ddl.add_field_section('mygroup', 'asec', 'a', TRUE);

then the field section is visible, and the section contents are visible to non-WITHIN queries, just like zone sections. interMedia Text accomplishes this by double-indexing the word (once as part of the extracted section, and once as part of the body), so this visible option does add to the space requirements for indexing.

See also: Main topics (outline), Getting started with interMedia Text