123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- # 2023 November 22
- #
- # The author disclaims copyright to this source code. In place of
- # a legal notice, here is a blessing:
- #
- # May you do good and not evil.
- # May you find forgiveness for yourself and forgive others.
- # May you share freely, never taking more than you give.
- #
- #***********************************************************************
- #
- # Tests focused on phrase queries.
- #
- source [file join [file dirname [info script]] fts5_common.tcl]
- set testprefix fts5origintext3
- # If SQLITE_ENABLE_FTS5 is not defined, omit this file.
- ifcapable !fts5 {
- finish_test
- return
- }
- foreach_detail_mode $testprefix {
- foreach {tn insttoken} {
- 1 0
- 2 1
- } {
- reset_db
- sqlite3_fts5_register_origintext db
- fts5_aux_test_functions db
- proc insttoken {cmd iIdx iToken} {
- set txt [$cmd xInstToken $iIdx $iToken]
- string map [list "\0" "."] $txt
- }
- sqlite3_fts5_create_function db insttoken insttoken
-
- do_execsql_test $tn.1.0 {
- CREATE VIRTUAL TABLE ft USING fts5(
- x, tokenize="origintext unicode61", tokendata=1, detail=%DETAIL%
- );
- }
- do_execsql_test $tn.1.0.1 {
- INSERT INTO ft(ft, rank) VALUES('insttoken', 1);
- }
-
- do_execsql_test $tn.1.1 {
- INSERT INTO ft VALUES('Hello world HELLO WORLD hello');
- }
-
- do_execsql_test $tn.1.2 {
- SELECT fts5_test_poslist(ft) FROM ft('hello');
- } {{0.0.0 0.0.2 0.0.4}}
- do_execsql_test $tn.1.3 {
- SELECT
- insttoken(ft, 0, 0),
- insttoken(ft, 1, 0),
- insttoken(ft, 2, 0)
- FROM ft('hello');
- } {hello.Hello hello.HELLO hello}
- do_execsql_test $tn.1.3.1 {
- SELECT
- insttoken(ft, 0, 0),
- insttoken(ft, 1, 0),
- insttoken(ft, 2, 0)
- FROM ft('hel*');
- } {hello.Hello hello.HELLO hello}
- do_execsql_test $tn.1.4 {
- SELECT
- insttoken(ft, 0, 0),
- insttoken(ft, 1, 0),
- insttoken(ft, 2, 0)
- FROM ft('hello') ORDER BY rank;
- } {hello.Hello hello.HELLO hello}
- do_execsql_test $tn.1.5 {
- CREATE VIRTUAL TABLE ft2 USING fts5(
- x, tokenize="origintext unicode61", tokendata=1, detail=%DETAIL%
- );
- INSERT INTO ft2(rowid, x) VALUES(1, 'ONE one two three ONE');
- INSERT INTO ft2(rowid, x) VALUES(2, 'TWO one two three TWO');
- INSERT INTO ft2(rowid, x) VALUES(3, 'THREE one two three THREE');
- }
- do_execsql_test $tn.1.6 {
- SELECT insttoken(ft2, 0, 0), rowid FROM ft2('three') ORDER BY rank;
- } {three.THREE 3 three 1 three 2}
- do_execsql_test $tn.1.7 {
- INSERT INTO ft2(rowid, x) VALUES(10, 'aaa bbb BBB');
- INSERT INTO ft2(rowid, x) VALUES(12, 'bbb bbb bbb');
- INSERT INTO ft2(rowid, x) VALUES(13, 'bbb bbb bbb');
- INSERT INTO ft2(rowid, x) VALUES(14, 'bbb BBB bbb');
- INSERT INTO ft2(rowid, x) VALUES(15, 'bbb bbb bbb');
- INSERT INTO ft2(rowid, x) VALUES(16, 'bbb bbb bbb');
- INSERT INTO ft2(rowid, x) VALUES(17, 'bbb bbb bbb');
- INSERT INTO ft2(rowid, x) VALUES(18, 'bbb bbb bbb');
- INSERT INTO ft2(rowid, x) VALUES(19, 'bbb bbb bbb');
- INSERT INTO ft2(rowid, x) VALUES(20, 'bbb bbb bbb');
- INSERT INTO ft2(rowid, x) VALUES(21, 'bbb bbb bbb');
- INSERT INTO ft2(rowid, x) VALUES(22, 'bbb bbb bbb');
- INSERT INTO ft2(rowid, x) VALUES(23, 'bbb bbb bbb');
- INSERT INTO ft2(rowid, x) VALUES(24, 'aaa bbb BBB');
- }
- do_execsql_test $tn.1.8 { SELECT rowid FROM ft2('aaa AND bbb'); } {10 24}
- do_execsql_test $tn.1.9 { SELECT rowid FROM ft2('bbb AND aaa'); } {10 24}
- do_execsql_test $tn.2.0 {
- CREATE VIRTUAL TABLE ft3 USING fts5(
- x, tokenize="origintext unicode61", tokendata=1, detail=%DETAIL%,
- prefix=2
- );
- }
- do_execsql_test $tn.2.1 {
- INSERT INTO ft3(rowid, x) VALUES(1, 'one');
- INSERT INTO ft3(rowid, x) VALUES(2, 'ONE');
- INSERT INTO ft3(rowid, x) VALUES(3, 'ONT');
- INSERT INTO ft3(rowid, x) VALUES(4, 'on');
- INSERT INTO ft3(rowid, x) VALUES(5, 'On');
- }
- do_execsql_test $tn.2.2 {
- SELECT rowid FROM ft3('on*');
- } {1 2 3 4 5}
- do_execsql_test $tn.2.3 {
- SELECT rowid, insttoken(ft3, 0, 0) FROM ft3('on*');
- } {1 one 2 one.ONE 3 ont.ONT 4 on 5 on.On}
- }
- }
- finish_test
|