*** 1,7 **** <html> <h1 align="center"> Full-text Search for SQLite<br> ! (as of 2006-09-19)<br> </h1> </html> --- 1,7 ---- <html> <h1 align="center"> Full-text Search for SQLite<br> ! (as of 2006-09-29)<br> </h1> </html> *************** *** 162,167 **** --- 162,192 ---- *:In column 0 (name), term 1 ("pie") matched at byte offset 8; the match is 3 bytes long (the length of "pie"). *:In column 1 (ingredients), term 0 ("sugar") matched at byte offset 8; the match is 5 bytes long (the length of "sugar"). + + *Generating snippets* + + fts1 can generate *snippets* of text surrounding each match returned in a full-text query. To produce a snippet, call the *snippet* function and pass it the name of your full-text table: + + sqlite> create virtual table poem using fts1(name, text); + sqlite> insert into poem values ('ozymandias', 'i met a traveller from an antique land who said: two vast and trunkless legs of stone stand in the desert'); + sqlite> select name, snippet(poem) from poem where text match 'land'; + ozymandias|i met a traveller from an antique <b>land</b> who said: two vast and trunkless legs of <b>...</b> + sqlite> + + By default, each matching term in a snippet is surrounded with the delimiters "<b>" and "</b>", and an ellipsis "..." indicates text not included in a snippet. (Note that the ellipsis is itself surrounded by delimiters "<b>" and "</b>".) + + You can specify your own term delimiters and ellipsis text by specifying extra arguments to the *snippet* function. Its arguments are as follows: + + 1:The name of the virtual table being queried. + 2:Markup to put before each matching word. Default: <b> + 3:Markup to put after each matching word. Default: </b> + 4:Ellipsis markup. Default: <b>...</b> + + For example: + + sqlite> select name, snippet(poem, '[', ']', '%%') from poem where text match 'land'; + ozymandias|i met a traveller from an antique [land] who said: two vast and trunkless legs of %% + sqlite> *Joining full-text data*