Defining Path Range Indexes
To define a range index expressed by an XPath expression, follow these steps:
If you are creating a path range index over XML data, create bindings for any namespaces prefixes used in your index XPath expression. For details, see Defining Namespace Prefixes Used in Path Range Indexes and Fields.
Click the Databases icon on the left tree menu.
Locate the database for which you want to create a range index, either in the tree menu or in the Database Summary table.
Click the name of the database for which you want to create a range index.
Click the Path Range Indexes icon in the tree menu, under the selected database.
Click the Add tab. The Path Range Index Configuration page appears.
Select the type of the XML element, XML attribute, or JSON property for which you want to build a range index.
If the index is of type
xs:string
, a collation box appears with a default collation. If you want the index to use a different collation than the default, enter the collation URI. You can click the Collation Builder button for a wizard that constructs the collation URI for you based on the language and other parameters you enter. For details about collations, see Language Support in MarkLogic Server in the Search Developer’s Guide.Enter the XPath expression in the path expression field. For XML, you can use any namespace prefix you created in Step 1. XPath expressions are summarized in XPath Quick Reference in the XQuery and XSLT Reference Guide. Not all XPath features are supported by path range indexes. For details, see Understanding Path Range Indexes.
Note
You can use the
cts:valid-index-path
function to test whether the path is syntactically correct for use in a path range index.You cannot have a path span across a fragment root. Paths should be scoped within fragment roots.
Choose whether to index range value positions for this index. Setting the value to
true
will speed the performance of searches that usects:near-query
,cts:element-query
, andcts:json-property-scope-query
with this index, but will use more disk space than leaving the positions off (range value positionsfalse
).In the invalid values field, choose whether to allow insertion of documents that contain XML elements, XML attributes, or JSON properties on which range index is configured, but the value of those elements, attributes, or properties cannot be coerced to the index data type. You can choose either
ignore
orreject
. By default, the server rejects insertion of such documents. However, if you chooseignore
, these documents can be inserted. This setting does not change the behavior of queries on invalid values after documents are inserted into the database. Performing an operation on an invalid value at query time can still result in an error.To add more indexes, click More Items and repeat Step 7 - Step 11 for each index as needed.
Scroll to the top or bottom and click OK.
The new path range index is added to the database. These rules are applied to XML or JSON documents loaded into the specified database from this point on.
Note
If you have reindexing enabled for the database and you specify an XML element, XML attribute, or JSON property that exists in a document, reindexing will run in the background. When the reindexing is complete, the new index will become available to queries.
Once you have created a path range index, you cannot change the path expression. Instead, you must remove the existing path range index and create a new one with the updated path expression.