XML index parameters syntax

You can use XML index parameters to index XML tag and attribute values in separate fields either by tag name, attribute name, or by path.

When you do not use XML index parameters, XML documents are indexed as unstructured text. The XML tags, attributes, and values are included in searches and are indexed together in the contents field.

Any JSON or BSON documents in an XML document are indexed as unstructured text.

Include XML index parameters in the bts index definition when you create the bts index. See bts access method syntax.

XML Index Parameters

1  xmltags = "
2.1  ( + , field )
2.1 file:directory/filename
2.1 table:table.column
1 "(1)
2.1+ ,
2.1  all_xmltags =
2.2.1 "no"
2.2.1? "yes"(2)
2.1  all_xmlattrs =
2.2.1 "no"
2.2.1? "yes"(3)
1+ ,
1  include_contents =
2.1 "no"
2.1? "yes"(4)
1  xmlpath_processing =
2.1 "no"
2.1? "yes"(5)
1  strip_xmltags =
2.1 "no"
2.1? "yes"(6)
1  include_namespaces =
2.1 "no"
2.1? "yes"(7)
1  include_subtag_text =
2.1 "no"
2.1? "yes"(8)
Table 1. Options for XML index parameters

Element Description
column The column that contains tags to index.
directory The location of the file that contains tags to index.
field The XML tag or path to index. The field values can be full or relative XML paths if used with the xmlpath_processing parameter.
filename The name of the file that contains tags to index.
table The name of the table that contains the column with tags to index.

Example

For example, you have the following XML fragment:
<skipper>Captain Black</skipper>
You can create a bts index for searching the text within the <skipper> </skipper> tags:
CREATE INDEX boats_bts ON boats(xml_data bts_lvarchar_ops) 
USING bts(xmltags="(skipper)") IN bts_sbspace;
To search for a skipper's name that contains the word "Black," use the bts search predicate:
bts_contains(xml_data, 'skipper:black')