1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Change the fts3 snippet function to return (hopefully) more relevant snippets in less time.

FossilOrigin-Name: 8a208223a74d451f60d9cd707d63fb7d157d1737
This commit is contained in:
dan
2010-01-06 17:19:21 +00:00
parent cf3e518506
commit b023b04fcb
9 changed files with 642 additions and 920 deletions

68
test/fts3snippet.test Normal file
View File

@ -0,0 +1,68 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
ifcapable !fts3 { finish_test ; return }
do_test fts3snippet-1.1 {
execsql {
CREATE VIRTUAL TABLE ft USING fts3;
INSERT INTO ft VALUES('xxx xxx xxx xxx');
}
} {}
proc normalize {L} {
set ret [list]
foreach l $L {lappend ret $l}
return $ret
}
do_test fts3snippet-1.2 {
execsql { SELECT offsets(ft) FROM ft WHERE ft MATCH 'xxx' }
} {{0 0 0 3 0 0 4 3 0 0 8 3 0 0 12 3}}
do_test fts3snippet-1.3 {
execsql { SELECT offsets(ft) FROM ft WHERE ft MATCH '"xxx xxx"' }
} [list [normalize {
0 0 0 3
0 0 4 3
0 1 4 3
0 0 8 3
0 1 8 3
0 1 12 3
}]]
do_test fts3snippet-1.4 {
execsql { SELECT offsets(ft) FROM ft WHERE ft MATCH '"xxx xxx" xxx' }
} [list [normalize {
0 0 0 3
0 2 0 3
0 0 4 3
0 1 4 3
0 2 4 3
0 0 8 3
0 1 8 3
0 2 8 3
0 1 12 3
0 2 12 3
}]]
do_test fts3snippet-1.5 {
execsql { SELECT offsets(ft) FROM ft WHERE ft MATCH 'xxx "xxx xxx"' }
} [list [normalize {
0 0 0 3
0 1 0 3
0 0 4 3
0 1 4 3
0 2 4 3
0 0 8 3
0 1 8 3
0 2 8 3
0 0 12 3
0 2 12 3
}]]
finish_test