• Start

Full-text search

Full-text search model

Learn how full-text search differs from literal matching, why SurrealDB fits FTS workloads, and where to find guides on analyzers, indexes, scoring, and non-FTS text operations.

A full-text search database is designed to index and retrieve text-based data (like articles, messages, or comments) based on tokenized and modified parts of the text itself, rather than exact, literal matches. This allows you to:

  • Find documents containing certain keywords.

  • Search for phrases or words with variants (e.g., “run,” “runs,” “running”).

  • Rank results by relevance, not just by literal string matches.

As a multi-model database, SurrealDB has integrated full-text search capabilities so that you can store your data and query it with advanced text search features.

Note: SurrealDB has many other built-in ways of working with text besides full-text search. For more details, see Other ways to work with text.

In traditional databases, you might do something like:

SELECT * FROM articles WHERE 'fox' IN title;

This approach:

  • Doesn’t rank results by relevance; it just returns every article containing “fox.”

  • Ignores language variations, e.g., “Foxes,” “FoX,” or synonyms like “vixen.”

  • May scan an entire table, making it slower for large datasets.

Full-text search, by contrast, uses an inverted index or other specialised structures for fast lookups and can handle a variety of linguistic transformations. It can highlight results and rank them by how relevant or frequent the terms are.

  • Unified model: You can keep your data, relationships, and search logic in a single engine.

  • Flexible schema: SurrealDB can be schemaless, so adding new fields or text columns doesn’t require schema migrations.

  • Powerful query language: SurrealQL blends SQL-like syntax with searching syntax (the @@ matching operator for FTS queries, advanced indexing features, and so on).

  • Real-time updates: SurrealDB can handle real-time changes, so newly inserted or updated text becomes searchable quickly.

There are three steps involved in full-text search:

  • Defining an analyzer

  • Defining an index that uses the analyzer

  • Querying using syntax that specifically uses full-text search

The guides in this section walk through each part.

For reference, see DEFINE INDEX, DEFINE ANALYZER, and Search functions.

Was this page helpful?