Fossil User Forum

How to search documents on Fossil CLI?
Login

How to search documents on Fossil CLI?

How to search documents on Fossil CLI?

(1.1) By Sean Ma (maxiangjiang) on 2019-03-27 21:32:56 edited from 1.0 [link] [source]

I found fossil search can only work on timeline entries, while /search is more powerful, which can "Search for check-in comments, documents, tickets, or wiki".

Is it possible to make CLI "fossil search" as powerful as Online "/search"?

(2) By Martijn Coppoolse (vor0nwe) on 2019-03-31 14:36:46 in reply to 1.1 [link] [source]

If search is setup properly (see page /srchsetup), you should be able to run a search command like this one:

fossil sql -list "SELECT name, label, snippet(ftsidx, '*', '*') AS hit FROM ftsidx INNER JOIN ftsdocs ON ftsidx.rowid = ftsdocs.rowid WHERE ftsidx MATCH 'test';" 

where you should replace the test at the end by your query. Seeing as this is quite a long command, it might be a good idea to write a shell script for it, if you want to use it more often. <style>code{background-color: rgba(222,222,222,0.5);white-space:pre-line}</style>

(3) By Stephan Beal (stephan) on 2019-03-31 14:48:18 in reply to 2 [source]

Just FYI, apparently you need to check the "Use Porter Stemmer" option at the bottom of /srcsetup or the query dies with no such table: ftsidx.

When running that query (after enabling the port stemmer), it ends with:

Error: sqlite3_close() returns 5: unable to close due to unfinalized statements or unfinished backups

here's the full session (and a great example of how triple-backtick code blocks would be really useful ;))...

[stephan@lapdog:~/www/wh]$  fossil sql -list "SELECT name, label, snippet(ftsidx, '*', '*') AS hit FROM ftsidx INNER JOIN ftsdocs ON ftsidx.rowid = ftsdocs.rowid WHERE ftsidx MATCH 'painting' limit 1;" 
|Check-in [49e19cb249d6511c] on 2019-03-11 09:58:26|Added /gaming/*painting*/, various touchups in/for the site CSS and index.html template. (user<b>...</b>
Error: sqlite3_close() returns 5: unable to close due to unfinalized statements or unfinished backups