document_search_content Client SQLite table
Local full-text search backing table for hydrated Loro documents.
Declared in packages/client-sdk/src/data/sqlite/schema/documentSearchSchema.ts
Description
Each row stores normalized, secret-filtered searchable text extracted by the active document projector registry. An explicit INTEGER PRIMARY KEY column (search_rowid) anchors both external-content FTS5 virtual tables (document_search_fts_word with unicode61 and document_search_fts_trigram with trigram) so SQLite VACUUM never renumbers rowids under FTS5.
Because the FTS5 virtual tables are purely derived, local database backups export this regular table and rebuild both FTS5 indexes on restore.
Columns
search_rowidinteger- primary key
- nullable
Integer primary key (an alias of the SQLite rowid) assigned on insert. Both FTS5 indexes use it as their rowid.
local_idtext- not null
- unique
local_idof the indexed document'sdocumentsrow.titletext- not null
- default ''
The document's title, at most 1,024 characters.
structured_texttext- not null
- default ''
Text of the document's structured fields and rows, at most 32,768 characters. The default extraction skips secret fields such as card numbers, CVV codes, and passwords.
attachment_texttext- not null
- default ''
Attachment text, at most 8,192 characters: by default the attachments' names.
body_texttext- not null
- default ''
The document's body text, at most 65,536 characters. The default extraction leaves it empty for
env_filedocuments.index_versioninteger- not null
- default 1
Version of the extraction rules (
DOCUMENT_SEARCH_INDEX_VERSION) that wrote the row. The backfill reindexes a row at any other version.snapshot_end_versiontext- not null
- default ''
The document's
snapshot_end_versionwhen the row was indexed. The backfill reindexes the row once the document's value differs.
Indexes
document_search_content_version_idx(index_version)
DDL
The statements the client runs to create this table and its indexes.
CREATE TABLE IF NOT EXISTS "document_search_content" (
"search_rowid" INTEGER PRIMARY KEY,
"local_id" TEXT NOT NULL UNIQUE,
"title" TEXT NOT NULL DEFAULT '',
"structured_text" TEXT NOT NULL DEFAULT '',
"attachment_text" TEXT NOT NULL DEFAULT '',
"body_text" TEXT NOT NULL DEFAULT '',
"index_version" INTEGER NOT NULL DEFAULT 1,
"snapshot_end_version" TEXT NOT NULL DEFAULT ''
);
CREATE INDEX IF NOT EXISTS "document_search_content_version_idx" ON "document_search_content" ("index_version");