feat: add fts5-based search

This commit is contained in:
Ellie Huxtable 2024-05-25 17:07:07 +01:00
parent 2e88321aec
commit 828181fd52

View File

@ -0,0 +1,14 @@
create virtual table history_fts using fts5(command, cwd, hostname, exit, content='history', tokenize='trigram');
insert into history_fts(rowid, command, cwd, exit, hostname) select rowid, command, cwd, exit, hostname from history;
-- Keep the index up to date
-- We do not ever update rows
-- for big changes, Atuin can just rebuild the history db from the store
CREATE TRIGGER history_fts_begin AFTER INSERT ON history BEGIN
INSERT INTO history_fts(rowid, command, cwd, exit, hostname) VALUES (new.rowid, new.command, new.cwd, new.exit, new.hostname);
END;
CREATE TRIGGER history_fts_delete AFTER DELETE ON history BEGIN
INSERT INTO history_fts(history_fts, rowid, command, cwd, exit, hostname) VALUES('delete', old.command, old.cwd, old.exit, old.hostname);
END;