Skip to main content

Administrating MarkLogic Server

Defining a Range Partition Key

The partition key describes a common element or attribute in the stored documents. The value of this element or attribute in the document determines the partition in which the document is stored. A partition key is based on a range index, collection lexicon, or field of the same name set for the database. The range index, collection lexicon, or field used by the partition key must be created before the partition key is created.

For example, assume your documents all have an update-date element with a date value. The following procedure describes how to create a partition key for the update-date element:

  1. Create an element range index, named update-date, on the database of type date. The details on how to create an element range index are described in Defining Element Range Indexes.

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

  3. Click your target database.

  4. On the Configure tab, scroll down and change the Assignment Policy field to range. Additional fields appear under the assignment policy.

  5. Choose whether the lower bound should be included in the assignment policy.

    1. Set Lower Bound Included to true if you want to include documents with a partition key value that matches the lower bound value, and exclude documents that match the upper bound value.

    2. Set Lower Bound Included to false if you want to exclude documents with a partition key value that matches the lower bound value, and include documents that match the upper bound value.

    For example, if the range is 2011-01-01 (lower) to 2012-01-01 (upper) and Lower Bound Included is set to false, documents with an update-date value of 2011-01-01 will not be included in the partition, but documents with an update-date value of 2011-01-02 and 2012-01-01 will be included.

  6. Set the Range indexes type and atomic type specification (scalar type) of the range index, field, or collection lexicon you want to use as your partition key. In this example, the range indexes type is Element and the atomic type specification (scalar type) is date.

  7. The range indexes, fields, or collection lexicons available are listed under the Name column. Select the value to use as your partition key ( update-date is selected in this example).

    Screenshot showing the range indexes, fields, or collection lexicons available listed under the Name column.