Skip to content

Instantly share code, notes, and snippets.

@TeddyDD
Created March 13, 2021 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TeddyDD/c5387fedb2c5a6ee7a206a86c1a370c9 to your computer and use it in GitHub Desktop.
Save TeddyDD/c5387fedb2c5a6ee7a206a86c1a370c9 to your computer and use it in GitHub Desktop.
Full text seach on files imported from fsdir in SQLite
CREATE virtual table file_search using fts5 (path, file, tokenize = 'unicode61');
INSERT into file_search
SELECT name,
data
FROM fsdir('some/path')
WHERE name like "%.md";
SELECT path,
snippet(file_search, 1, '', '', '...', 5) AS snippet
FROM file_search
WHERE file_search match 'some query';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment