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

{ xmltags=" { ( field ) | file:directory/filename | table:table.column } " (explicit id ) | { | all_xmltags= { "no" | [ "yes" ] } (explicit id ) | all_xmlattrs= { "no" | [ "yes" ] } (explicit id ) } }
[ { | include_contents= { "no" | [ "yes" ] } (explicit id ) | xmlpath_processing= { "no" | [ "yes" ] } (explicit id ) | strip_xmltags= { "no" | [ "yes" ] } (explicit id ) | include_namespaces= { "no" | [ "yes" ] } (explicit id ) | include_subtag_text= { "no" | [ "yes" ] } (explicit id ) } ]
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')