MasterRecord

Full-Text Search

Index and search large text columns natively.

For content-heavy tables, a LIKEscan won’t cut it. MasterRecord supports full-text indexes so you can search documents, articles, and descriptions efficiently.

Add a full-text index in a migration#

migration
async up(table) {
  await this.init(table);
  await this.createTable(table.Document);
  await this.createFullTextIndex({
    table: 'documents',
    columns: ['title', 'body'],
    name: 'documents_fts',
  });
}

Searching#

search.js
const results = await db.Document
  .search('grayskull power')          // full-text match
  .where((d) => d.workspace_id == $$, workspaceId)
  .take(20)
  .toList();
Engine differences
Full-text search maps to each engine’s native capability — SQLite FTS5, MySQL FULLTEXT, and PostgreSQL tsvector/tsquery. The MasterRecord API stays the same; the generated SQL adapts per database.