Skip to main content

Administrating MarkLogic Server

Defining Path Range Indexes

To define a range index expressed by an XPath expression, follow these steps:

  1. 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.

  2. Click the Databases icon on the left tree menu.

  3. Locate the database for which you want to create a range index, either in the tree menu or in the Database Summary table.

  4. Click the name of the database for which you want to create a range index.

  5. Click the Path Range Indexes icon in the tree menu, under the selected database.

  6. Click the Add tab. The Path Range Index Configuration page appears:

    path_range_add_v10.gif
  7. Select the type of the XML element, XML attribute, or JSON property for which you want to build a range index.

  8. 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.

  9. 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.

  10. Choose whether to index range value positions for this index. Setting the value to true will speed the performance of searches that use cts:near-query, cts:element-query, and cts:json-property-scope-query with this index, but will use more disk space than leaving the positions off (range value positions false).

  11. 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 or reject. By default, the server rejects insertion of such documents. However, if you choose ignore, 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.

  12. To add more indexes, click More Items and repeat Step 7 - Step 11 for each index as needed.

  13. 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.