CipherStash
CipherStash Documentation

Match

Match supports full text search across one or more string fields in queries.

Supported Types

  • string

Index Definition

Match can include strings from multiple fields within the same index. A Match index also requires some configuration and accepts an object with tokenFilters and tokenizer fields.

There are are currently only two token filters available downcase and upcase. These are used to normalise the text before indexing and are also applied to query terms. An empty array can also be passed to tokenFilters if no normalisation of terms is required.

There are two tokenizers provided: standard and ngram. The standard simply splits text into tokens using this regular expression: /[ ,;:!]/. The ngram tokenizer splits the text into n-grams and accepts a configuration object that allows you to specify the tokenLength.

import { CollectionSchema, downcase, ngram } from "@cipherstash/stashjs"

CollectionSchema.define<Employee>("employees").indexedWith(mapping => ({
  nameAndJobTitle: mapping.Match(["name", "jobTitle"], {
    tokenFilters: [downcase],
    tokenizer: ngram({ tokenLength: 3 })
  })
})

Supported Query Operations

  • match (performs full text search)
let queryResult1 = await employees.all(
  employee => employee.nameAndJobTitle.match("CEO")
)