Skip to main content

Administrating MarkLogic Server

Defining Attribute Range Indexes

To define a range index for an attribute of a particular element, follow these steps:

  1. Click Databases in the left tree menu. A list of databases appears.

  2. Click your target database.

  3. In the tree menu, under the selected database, click Attribute Range Indexes.

  4. Click the Add tab.

  5. From the Scalar Type list, select the type of the XML element.

  6. Enter the namespace URI of the XML element that contains the attribute you want to index into theParent Namespace Uri field.

    Every XML element is associated with a namespace. For the description of the element to be precise, you must specify the namespace of the XML element. The asterisk (*) cannot be used to indicate namespace independence. Leaving the namespace URI field blank specifies the universal unnamed namespace.

  7. Enter the element name in the Parent Localname field.

    The local name is the name of the XML element that contains the attribute to be indexed. If you have more than one element in the same namespace that contains the attribute you want to index, you can provide a comma-separated list of element names.

  8. Enter the namespace URI of the attribute that you want to index into the Namespace URI field.

    Every XML attribute is associated with a namespace. For the description of the attribute to be precise, you must specify the namespace of the XML attribute. The asterisk (*) cannot be used to indicate namespace independence. Leaving the Namespace URI field blank specifies the universal unnamed namespace.

  9. Enter the attribute name in the Localname field.

    The local name is the name of the XML attribute to be indexed. If you have more than one attribute in the same namespace within the specified parent element(s) that you want to index, you can provide a comma-separated list of attribute names.

  10. If you selected a scalar type of string in Step 5, the Collation field contains a default collation. You can enter a different collation URI or 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.

  11. Set the Range Value Positions field to true to increase the speed of searches that use cts:near-query and cts:element-query with this index. However, this setting uses more disk space than the default setting of false.

  12. In the invalid values field, choose whether to allow insertion of documents that contain attributes on which range index is configured, but the value of those attributes 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.

  13. To add more indexes, click More Items and repeat Step 5 - Step 12 for each attribute index as needed.

  14. Scroll to the top or bottom and click OK.

The new attribute index is added to the database. These rules are applied to XML documents loaded into the specified database from this point on.

Note

If you have reindexing enabled for the database and you specify an element-attribute pair that exists in a document, reindexing will run in the background. When the reindexing is complete, the new index will become available to queries.