CipherStash Documentation


Range supports range operations in queries. It is also the index type used when returning query results in order.

Supported Types

A Range index can be defined on the following types

Supported Query Operations

  • lt (less than)
  • lte (less than or equal)
  • eq (equal)
  • gt (greater than)
  • gte (greater than or equal)
  • between (indexed value is in between two supplied values)

String Ordering

Range indexes can be used to sort encrypted strings. This feature is somewhat experimental, and thus is not fully-featured yet.

Currently, only printable ASCII characters are supported. Within that subset, characters are sorted in this order:

  1. letters, case-insensitively sorted in alphabetic order; then
  2. whitespace; then
  3. all digits are considered “equal”; then
  4. then all punctuation is also considered “equal”.

Only the first 80 or characters of the string are subject to sorting.

Further advancements, including full UTF-8 and locale-specific ordering rules, are planned. Let us know on our support site if you are particularly interested in this feature.

Index Definition

Range indexes can be defined with the "range" kind in a JSON schema definition:

  // (type definition omitted)
  "indexes": {
    "startDate": { "kind": "range", "field": "startDate" }


StashRB (Ruby)

StashJS (TypeScript)