Skip to content

Build your personal knowledge base with Trilium Notes

feat(search): add FTS5 migration for content search index

perfectra1nac13af73c50d
diff --git a/apps/server/src/migrations/0235__add_fts5_content_search.ts b/apps/server/src/migrations/0235__add_fts5_content_search.ts
new file mode 100644
index 0000000000..d0767d51b4
--- /dev/null
+++ b/apps/server/src/migrations/0235__add_fts5_content_search.ts
@@ -0,0 +1,14 @@
+import sql from "../services/sql.js";
+import log from "../services/log.js";
+
+export default () => {
+ sql.execute(/*sql*/`
+ CREATE VIRTUAL TABLE IF NOT EXISTS note_content_fts USING fts5(
+ noteId UNINDEXED,
+ content,
+ tokenize='unicode61 remove_diacritics 2'
+ )
+ `);
+
+ log.info("Created note_content_fts table. FTS index will be populated on first search.");
+};
diff --git a/apps/server/src/migrations/migrations.ts b/apps/server/src/migrations/migrations.ts
index 7aca1f802b..e9f8b8d72d 100644
--- a/apps/server/src/migrations/migrations.ts
+++ b/apps/server/src/migrations/migrations.ts
@@ -6,6 +6,11 @@
// Migrations should be kept in descending order, so the latest migration is first.
const MIGRATIONS: (SqlMigration | JsMigration)[] = [
+ // Add FTS5 virtual table for full-text content search
+ {
+ version: 235,
+ module: async () => import("./0235__add_fts5_content_search.js")
+ },
// Migrate aiChat notes to code notes since LLM integration has been removed
{
version: 234,