Defining a Range Partition Key
- Last Updated: April 14, 2026
- 2 minute read
- MarkLogic Server
- Version 10.0
- Documentation
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:
-
Create an element range index, named
update-date, on the database of typedate. The details on how to create an element range index are described in Defining Element Range Indexes. -
In the Admin Interface, open the configuration page for the database, and set the assignment policy to range. Additional settings appear under the assignment policy.
-
Set the
Lower Bound Includedtotrueif 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. Set theLower Bound Includedtofalse, 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 is2011-01-01(lower) to2012-01-01(upper) andLower Bound Includedis set tofalse, documents with anupdate-datevalue of2011-01-01will not be included in the partition, but documents with anupdate-datevalue of2011-01-02and2012-01-01will be included. -
Note the type and scalar type of the range index, field, or collection lexicon you want to use as your partition key. In this example, we use an
Elementrange index with a scalar type ofdate. Set the index and scalar types in the drop down menus to list the matching range indexes, fields, or collection lexicons set for the database. -
Select the range index, field, or collection lexicon you want to use as your partition key, which is
update-datein this example: