CipherStash
CipherStash Documentation

Field dynamic match query

By adding a field dynamic match index to the schema, all string fields will be indexed, as well as the field name.

Using a field dynamic match query you are able to do a full text search on a specific field.

import { Stash } from "@cipherstash/stashjs"
import { generateSchemaWithMapping } from "./schemaWithMapping";

const matchQuery = async () => {
    try {
        const stash = await Stash.connect();

        const movieSchema = await generateSchemaWithMapping()

        const movies = await stash.loadCollection(movieSchema)

        const queryResult = await movies.query(
          movie => movie.allTextFieldDynamicMatch.match("title", "odyssey")
        )


        console.log(queryResult)
        return queryResult
      } catch (err) {
        console.error(err)
        console.error(`Could not query collection! Reason: ${JSON.stringify(err)}`)
        return
      }
}

matchQuery()