CipherStash Documentation

Querying for Records With Matching Text

A match index provides full-text search capabilities on encrypted data. To query a match index, you use the match operator on any index defined as a match index. The same tokenization strategy that was applied to the indexed text will also be applied to your query text.

For example, if you have an index defined like this:

  "type" => {
    "name" => "string",
    "address" => "string"
  "indexes" => {
    "myMatchIndex" => {
      "kind" => "match",
      "fields" => ["name", "address"],
      "tokenizer" => "standard",
      "tokenFilters" => [
        { "kind" => "downcase" },
        { "kind" => "ngram", "tokenLength" => 3 }

Then you can find all records that have the string “Tuesday” in the name or address fields like this:

collection.query do |r|