CipherStash Documentation


FieldDynamicMatch is like DynamicMatch but allows match queries to be scoped to specific fields not known ahead of time.

Supported Types

Index Definition

FieldDynamicMatch works just like DynamicMatch in that all string fields in a document will be indexed. However, it also indexes the field names of the string fields and provides an enhanced match function at query time.

FieldDynamicMatch indexes can be defined with the "field-dynamic-match" kind in a JSON schema definition:

  // (type definition omitted)
  "indexes": {
    "allText": {
      "kind": "field-dynamic-match",
      "tokenFilters": [{ "kind": "downcase" }],
      "tokenizer": { "kind": "ngram", "tokenLength": 3 }

Supported Query Operations

  • match (performs full text search)

Imagine that we have an employees collection but that the only index we have defined is called allText of type FieldDynamicMatch. In this case, even though we have not defined an index specifically for the jobTitle field, we can still perform a full text search narrowed down to that specific field.

StashJS (TypeScript)

let queryResult1 = await employees.all(
  employee => employee.allText.match("jobTitle", "CEO")