Skip to main content

Administrating MarkLogic Server

Defining Element Range Indexes

To define a range index for an XML element or JSON property, follow these steps:

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

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

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

  4. Click the Element Range Indexes icon in the tree menu, under the selected database.

  5. Click the Add tab. The Add Range Indexes configuration page appears:

    range_add_v10.gif
  6. Select the type of the XML element or JSON property for which you want to build a range index.

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

  8. Enter the namespace URI of the XML element. Skip this step for a JSON property index.

    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.

  9. Enter the element or JSON property name in the localname field.

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

  10. Choose whether to index range value positions for this index. Setting range value positions to true will speed the performance of searches that use cts:near-query and cts:element-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 elements or JSON properties on which range index is configured, but the value of those elements 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 6 - Step 11 for each index as needed.

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

The new element range index or element word lexicon is added to the database. These rules are applied to XML and JSON documents loaded into the specified database from this point on.

Note

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