I've followed https://kimsereylam.com/sqlite/2020/03/06/full-text-search-with-sqlite.html to set up SQLite's virtual table extension FTS5 for full text search on an external content table. While the blog shows how to set up triggers to keep the virtual FTS table updated with the data:
CREATE TABLE user (
id INTEGER PRIMARY KEY,
username TEXT NOT NULL UNIQUE,
email TEXT NOT NULL UNIQUE,
short_description TEXT
)
CREATE VIRTUAL TABLE user_fts USING fts5(
username,
short_description,
email UNINDEXED,
content='user',
content_rowid='id'
)
CREATE TRIGGER user_ai AFTER INSERT ON user
BEGIN
INSERT INTO user_fts (rowid, username, short_description)
VALUES (new.id, new.username, new.short_description);
END;
...
I am failing to populate the FTS table from all previous data in an analogous fashion. I'll stick to the example from the blog:
INSERT INTO user_fts (rowid, username, short_description) SELECT (id, username, short_description) FROM user;
However, sqlite (3.37.2) fails with row value misused
.
Please explain how id
, content_rowid
, rowid
and new.id
are related and how to modify the query to update the FTS table properly.