engine: Convert from SQLite FTS3/4 to FTS5 for full-text-search

Add SQL migration that drops the old FTS4 MessageSearchTable table,
re-create as a FTS5 table, clean up the column names a bit, and adds a
flags column so unread/starred queries can be made fast.

Define a SQLite FTS5 extension function `geary_matches()` to replace
the FTS3 `offsets()` function which no longer exists in FTS5, based on
Tracker's implementation.

Update code to FTS5 conventions (docid -> rowid, etc), use new column
names, populate and update the flags column as the email's flags
change, and use new match function for getting matching tokens.

Advanced searches are probably currently broken, these will be fixed
by subsequent commits.
This commit is contained in:
Michael Gratton 2020-11-04 00:55:13 +11:00 committed by Michael James Gratton
parent 435a5e90f4
commit 4fe0d92147
13 changed files with 266 additions and 63 deletions

19
sql/version-030.sql Normal file
View file

@ -0,0 +1,19 @@
--
-- Convert full-text search from FTS3/4 to FTS5
--
DROP TABLE IF EXISTS MessageSearchTable;
CREATE VIRTUAL TABLE MessageSearchTable USING fts5(
body,
attachments,
subject,
"from",
receivers,
cc,
bcc,
flags,
tokenize="unicode61 remove_diacritics 2",
prefix="2,4,6,8,10"
)