3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
12 # Tests focused on phrase queries.
15 source [file join [file dirname [info script]] fts5_common.tcl]
16 set testprefix fts5origintext2
18 # If SQLITE_ENABLE_FTS5 is defined, omit this file.
24 sqlite3_fts5_register_origintext db
26 CREATE VIRTUAL TABLE ft USING fts5(
27 x, tokenize="origintext unicode61", tokendata=1
33 INSERT INTO ft VALUES('Hello');
34 INSERT INTO ft VALUES('hello');
35 INSERT INTO ft VALUES('HELLO');
36 INSERT INTO ft VALUES('today');
37 INSERT INTO ft VALUES('today');
38 INSERT INTO ft VALUES('today');
39 INSERT INTO ft VALUES('World');
40 INSERT INTO ft VALUES('world');
41 INSERT INTO ft VALUES('WORLD');
45 do_execsql_test 1.2 { SELECT rowid FROM ft('hello'); } {1 2 3}
46 do_execsql_test 1.3 { SELECT rowid FROM ft('today'); } {4 5 6}
47 do_execsql_test 1.4 { SELECT rowid FROM ft('world'); } {7 8 9}
50 SELECT count(*) FROM ft_data
55 INSERT INTO ft(ft, rank) VALUES('pgsz', 64);
58 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100
60 INSERT INTO ft SELECT 'Hello Hello Hello Hello Hello Hello Hello' FROM s;
61 INSERT INTO ft VALUES ('hELLO hELLO hELLO');
62 INSERT INTO ft VALUES('today today today today today today today');
63 INSERT INTO ft VALUES('today today today today today today today');
64 INSERT INTO ft VALUES('today today today today today today today');
65 INSERT INTO ft VALUES('today today today today today today today');
66 INSERT INTO ft VALUES('today today today today today today today');
67 INSERT INTO ft VALUES('today today today today today today today');
68 INSERT INTO ft VALUES('World World World World World World World');
69 INSERT INTO ft VALUES('world world world world world world world');
70 INSERT INTO ft VALUES('WORLD WORLD WORLD WORLD WORLD WORLD WORLD');
71 INSERT INTO ft VALUES('World World World World World World World');
72 INSERT INTO ft VALUES('world world world world world world world');
73 INSERT INTO ft VALUES('WORLD WORLD WORLD WORLD WORLD WORLD WORLD');
78 SELECT count(*) FROM ft_data;
81 do_execsql_test 1.8 { SELECT rowid FROM ft('hello') WHERE rowid>100; } {101}
85 INSERT INTO ft(ft) VALUES('optimize');
86 SELECT count(*) FROM ft_data;
88 do_execsql_test 1.10 {
90 INSERT INTO ft VALUES('Hello');
91 INSERT INTO ft VALUES('hello');
92 INSERT INTO ft VALUES('HELLO');
93 INSERT INTO ft VALUES('today');
94 INSERT INTO ft VALUES('today');
95 INSERT INTO ft VALUES('today');
96 INSERT INTO ft VALUES('World');
97 INSERT INTO ft VALUES('world');
98 INSERT INTO ft VALUES('WORLD');
101 do_execsql_test 1.11 { SELECT rowid FROM ft('hello'); } {1 2 3}
102 do_execsql_test 1.12 { SELECT rowid FROM ft('today'); } {4 5 6}
103 do_execsql_test 1.13 { SELECT rowid FROM ft('world'); } {7 8 9}
104 do_execsql_test 1.14 { SELECT rowid FROM ft('hello') ORDER BY rank; } {1 2 3}
106 #------------------------------------------------------------------------
108 sqlite3_fts5_register_origintext db
111 for {set iTok 0} {$iTok < [$cmd xInstCount]} {incr iTok} {
112 set txt [$cmd xInstToken $iTok 0]
113 set txt [string map [list "\0" "."] $txt]
118 sqlite3_fts5_create_function db tokens tokens
120 do_execsql_test 2.0 {
121 CREATE VIRTUAL TABLE x1 USING fts5(
122 v, tokenize="origintext unicode61", tokendata=1, detail=none
125 INSERT INTO x1 VALUES('xxx Xxx XXX yyy YYY yyy');
126 INSERT INTO x1 VALUES('xxx yyy xxx yyy yyy yyy');
129 do_execsql_test 2.1 {
130 SELECT tokens(x1) FROM x1('xxx');
132 {xxx xxx.Xxx xxx.XXX} {xxx xxx}
135 do_execsql_test 2.2 {
136 UPDATE x1_content SET c0 = 'xxx xxX xxx yyy yyy yyy' WHERE id=1;
139 do_execsql_test 2.3 {
140 SELECT tokens(x1) FROM x1('xxx');
142 {xxx {} xxx} {xxx xxx}