Full Text Search

Nymph provides a case insensitive full text search engine based on the SciActive Tokenizer. It has the ability to search for sequential tokens, exact tokens, "or" searches, and negation of tokens.

The following example queries show how to use the available features.

  • light - matches "light", "lights", "lighting", "lighted"
  • light mode - matches "light mode", "The disctinct mode ... bright lighting around..."
  • 'light mode' - matches "light mode", "lighting mode", "lighting the mode", "lighted and moded"
  • "light mode" - matches "light mode", "light and mode", "light a mode"
  • light or dark - matches "this is light", "dark is here"
  • "light mode" or "dark mode" - matches "light mode on", "dark and mode"
  • -light - matches anything without "light", "lights", "lighting", "lighted", and other unstemmed forms
  • -'light mode' - matches anything without "light mode", "lighting mode", "lighting the mode", "lighted and moded", etc.
  • -"light mode" - matches anything without "light mode", "light and mode", "light a mode"
  • "light mode" or -"grayscale" - matches "light mode", "light and mode", "light a mode", or anything without "grayscale"

You can use the search feature with the search clause in a Nymph query:

nymph.getEntities(
  { class: SomeEntity },
  { type: '&', search: ['prop', 'light mode'] },
);

One thing to note is that this is not a substring search, so a search for "light" will not match the words "slight", "blight", or "delighted".

When an entity is saved into the database, it has a chance (through the getFTSText static method) to alter text from its properties before FTS indexing (removing HTML tags, extracting text from Base64, etc). Once the text is finalized, it's converted to lower case, broken apart into words, stop words are removed, each word is stemmed (running -> run, etc), and the stem and the original are turned into 32-bit tokens. The tokens, along with their position and whether they're a stem, are stored in the database.

The default getFTSText static method will return the value of the property if it is a string, or null if it is not a string. You can reimplement this method. To cause Nymph to index a value, return a string from this method. To cause Nymph to ignore it, making it not searchable with search clauses, return null.

If you have an entity that stores a value as a string that isn't meant to be full text indexed, you should implement this method and return null for that property, otherwise you will waste disk space indexing it.

Previous: Transactions Next: Export and Import