SQLite Forum

Unable to search an FTS5 trigram table when using external content
Login
An external content table is like a contentless table in that the user has to arrange to update the FTS index using INSERT statements to keep it in sync with the external table.

<pre>
    sqlite> CREATE TABLE test(id INTEGER PRIMARY KEY AUTOINCREMENT, data TEXT);
    sqlite> INSERT INTO test(data) VALUES('testing foo bar');
    sqlite> CREATE VIRTUAL TABLE fts USING fts5(data, content=test, content_rowid=id, tokenize='trigram');
    sqlite> <b>INSERT INTO fts(rowid, data) SELECT id, data FROM test;</b>
    sqlite> SELECT * FROM fts('foo');
    testing foo bar
</pre>

One way to do this is with triggers, another is to have your app update both the external content table and the fts index at the same time. See documentation here:

[](https://sqlite.org/fts5.html#external_content_and_contentless_tables)

For small tables, the 'rebuild' command can be useful:

[](https://sqlite.org/fts5.html#the_rebuild_command)