Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(search): wire FTS index updates to note content changes
perfectra1nf358563c27de
diff --git a/apps/server/src/services/handlers.ts b/apps/server/src/services/handlers.tsindex f32bf6ddd0..89647d8d83 100644--- a/apps/server/src/services/handlers.ts+++ b/apps/server/src/services/handlers.ts@@ -60,6 +60,17 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED} else if (entityName === "notes") {// ENTITY_DELETED won't trigger anything since all branches/attributes are already deleted at this pointrunAttachedRelations(entity, "runOnNoteChange", entity);++ if (entity.isDeleted) {+ try {+ const ftsIndex = require("./search/fts_index.js").default;+ if (ftsIndex.isIndexBuilt()) {+ ftsIndex.removeNote(entity.noteId);+ }+ } catch {+ // FTS index update failure should not block note operations+ }+ }}});@@ -81,6 +92,16 @@ eventService.subscribe(eventService.ENTITY_CHANGED, ({ entityName, entity }) =>eventService.subscribe(eventService.NOTE_CONTENT_CHANGE, ({ entity }) => {runAttachedRelations(entity, "runOnNoteContentChange", entity);++ // Update FTS content index incrementally+ try {+ const ftsIndex = require("./search/fts_index.js").default;+ if (ftsIndex.isIndexBuilt()) {+ ftsIndex.updateNote(entity.noteId);+ }+ } catch {+ // FTS index update failure should not block note saves+ }});eventService.subscribe(eventService.ENTITY_CREATED, ({ entityName, entity }) => {