Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite FTS4 snippet argument format

Tags:

sqlite

I'm working on analyzing texts in RQDA and am using the Firefox SQLite Manager to access the database so that I can search files more easily. I've created and populated virtual table:

CREATE VIRTUAL TABLE texts USING fts4(filename, content)

Then I did a snippet search

SELECT snippet(texts, '_', '_', '...') FROM texts WHERE texts MATCH 'great OR Great'; 

This returns results where the snippet term is highlighted with an underscore.

My questions:

  1. How do I implement the 6th argument (documentation) so to increase the snippet size? (I see a similar question on this but the response does not work.)
  2. How can I get the MATCH return to also show the filename for the snippet (first column in my table.) So the format will be "filename", "snippet".

Thanks in advance for your help.

like image 859
Prefontaine Avatar asked Jul 02 '26 15:07

Prefontaine


1 Answers

So I figured it out! Documentation on 6th parameter was not so clear...

SELECT filename, snippet(texts, '_', '_', '...', -30, 30) FROM texts WHERE texts MATCH 'great OR Great';

This displays the filename and snippet with 30 words before and after search term.

like image 53
Prefontaine Avatar answered Jul 05 '26 16:07

Prefontaine



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!