The combined index type and syntax type is called the index strategy. There are two ways that you can specify an index; by using a string or by specifying enumerated types. Most of the APIs that you use to manage indices support both mechanisms. However, a few support only strings.
The string that you use to specify an indexing strategy is formatted as follows:
[unique]-{path type}-{node type}-{key type}-{syntax type}
where:
unique is the actual value that you provide in this position on the string. If you provide this value, then indexed values must be unique. If you do not want indexed values to be unique, provide nothing for this position in the string.
See Uniqueness for more information.
{path type} identifies the path type. Valid values are:
node
edge
See Path Types for more information.
{node type} identifies the type of node being indexed. Valid values are:
element
attribute
metadata
If metadata is specified, then {path type} must be node.
See Node Types for more information.
{key type} identifies the sort of test that the index supports. The following key types are supported:
presence
equality
substring
See Key Types for more information.
{syntax type} identifies the syntax to use for the indexed value. Specify one of the following values:
none
anyURI
base64Binary
boolean
date
dateTime
dayTimeDuration
decimal
double
duration
float
gDay
gMonth
gMonthDay
gYear
gYearMonth
hexBinary
NOTATION
QName
string
time
yearMonthDuration
untypedAtomic
Note that if the key type is presence, then the syntax type should be none.
The following are some example index strategies:
node-element-presence-none
Index an element node for presence queries. That is, queries that test whether the node exists in the document.
unique-node-metadata-equality-string
Index a metadata node for equality string compares. The value provided for this node must be unique within the container.
This strategy is actually used by default for all documents in a container. It is used to index the document's name.
edge-attribute-equality-float
Defines an equality float index for an attribute's edge. Improves performance for queries that examine whether a specific element/@attribute path is equal to a float value.
Also, be aware that you can specify multiple indices at a time by providing a space-separated list of index strategies in the string. For example, you can specify two index strategies at a time using:
"node-element-presence-none edge-attribute-equality-float"
When you use enumerated types to specify index strategies, the API will provide two parameters. The first defines the index type, and the second defines the index syntax.
You specify the index syntax using an XmlValue::Type value. See Enumerated Index Syntax for more information.
Be aware that, unlike index strategies specified as strings, you cannot specify multiple index strategies in a single API call when you are using enumerated types.
To specify an index type, you provide a series of XmlIndexSpecification::Type values or'd together. Each value that you provide identifies a specific aspect of the index type: uniqueness, path type, node type, and key type. To specify:
uniqueness, provide XmlIndexSpecification::UNIQUE_ON to the index type value. If you provide nothing, then uniqueness is not enforced. For code readability purposes, you can optionally use XmlIndexSpecification::UNIQUE_OFF to suppress uniqueness as well.
the path type, use one of:
XmlIndexSpecification::PATH_NODE
XmlIndexSpecification::PATH_EDGE
the node type, use one of:
XmlIndexSpecification::NODE_ELEMENT
XmlIndexSpecification::NODE_ATTRIBUTE
XmlIndexSpecification::NODE_METADATA
Note that if XmlIndexSpecification::NODE_METADATA is used, then XmlIndexSpecification::PATH_NODE must also be used.
the key type, use one of:
XmlIndexSpecification::KEY_PRESENCE
XmlIndexSpecification::KEY_EQUALITY
XmlIndexSpecification::KEY_SUBSTRING.
For example, to specify the type, or the values together like this:
XmlIndexSpecification::UNIQUE_ON | XmlIndexSpecification::PATH_NODE | XmlIndexSpecification::NODE_ATTRIBUTE | XmlIndexSpecification::KEY_EQUALITY
See Enumerated Index Example for an example of how to use these types.
To identify the syntax type for the index strategy using enumerated types, use XmlValue::Type values. The following values are available for you to use:
XmlValue::NONE
XmlValue::NODE
XmlValue::ANY_SIMPLE_TYPE
XmlValue::ANY_URI
XmlValue::BASE_64_BINARY
XmlValue::BOOLEAN
XmlValue::DATE
XmlValue::DATE_TIME
XmlValue::DAY_TIME_DURATION
XmlValue::DECIMAL
XmlValue::DOUBLE
XmlValue::DURATION
XmlValue::FLOAT
XmlValue::G_DAY
XmlValue::G_MONTH
XmlValue::G_MONTH_DAY
XmlValue::G_YEAR
XmlValue::G_YEAR_MONTH
XmlValue::HEX_BINARY
XmlValue::NOTATION
XmlValue::QNAME
XmlValue::STRING
XmlValue::TIME
XmlValue::YEAR_MONTH_DURATION
XmlValue::UNTYPED_ATOMIC
Methods that accept numerated types for specifying index strategies always have a parameter for the index type and a parameter for the index syntax. The following are examples of the values you would give to these parameters when specifying an index strategy:
String equivalent: node-element-presence-none
For index type:
XmlIndexSpecification::PATH_NODE | XmlIndexSpecification::NODE_ELEMENT | XmlIndexSpecification::KEY_PRESENCE
For parameter type:
XmlValue::NONE
String equivalent: unique-node-metadata-equality-string
XmlIndexSpecification::UNIQUE_ON | XmlIndexSpecification::PATH_NODE | XmlIndexSpecification::NODE_METADATA | XmlIndexSpecification::KEY_EQUALITY
For parameter type:
XmlValue::STRING
edge-attribute-equality-float
XmlIndexSpecification::EDGE_NODE | XmlIndexSpecification::NODE_ATTRIBUTE | XmlIndexSpecification::KEY_EQUALITY
For parameter type:
XmlValue::FLOAT