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:
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.Click Databases in the left tree menu. A list of databases appears.
Click your target database.
On the Configure tab, scroll down and change the Assignment Policy field to range. Additional fields appear under the assignment policy.
Choose whether the lower bound should be included in the assignment policy.
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.
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) to2012-01-01
(upper) and Lower Bound Included is set to false, documents with anupdate-date
value of2011-01-01
will not be included in the partition, but documents with anupdate-date
value of2011-01-02
and2012-01-01
will be included.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.
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).