Skip to content

Query Syntax

staticseek supports a variety of query syntaxes to enhance search capabilities:

By default, staticseek performs fuzzy search with an edit distance of 1, meaning it tolerates one character error per search term. You can adjust this tolerance in two ways:

  • For individual searches, specify the edit distance in the query:

    distance:2 searchterm // Allows up to 2 character differences
  • To set a different default edit distance for all searches, configure it during index creation:

    const index = createIndex(LinearIndex, array_of_articles, {
    distance: 2 // Set default edit distance for all searches
    });

Use double quotes for exact phrase matching:

"exact phrase" // Matches the exact phrase including spaces

Use \" to include double quotes in the search term.

  • AND Search: Space-separated terms (both terms must match)

    term1 term2 // Documents containing both terms
  • OR Search: Terms separated by OR (either term can match)

    term1 OR term2 // Documents containing either term
  • NOT Search: Terms prefixed with minus (exclude documents with term)

    -term1 term2 // Documents with term2 but without term1

    Note: NOT search must be used with AND search; standalone NOT terms are ignored.

Limit search to specific fields:

from:title searchterm // Search only in title field

There are two ways to specify fields in a query:

  1. Full path: Use the full path to the field, starting from the root object:
    from:data.title searchterm
  2. Field name only: If the field is a leaf, you can specify the field name directly:
    from:title searchterm

You can only specify leaf fields. If you specify a non-leaf field, the results of the search is empty.

When executing queries, it is important to handle potential errors. If the query fails or if the provided index is invalid, a StaticSeekError will be returned. Ensure to check for this error and handle it appropriately in your application.