1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00
Files
sqlite/ext/fts5/test/fts5tokendata.test
dan e25a267e81 Fix the fts5 xInstToken() API for prefix queries that do not use prefix-indexes. This is experimental.
FossilOrigin-Name: 97c2824f471e7e622c4a166947a6e8162cae891345101539829a6fcec83373fe
2024-09-14 20:30:14 +00:00

106 lines
2.5 KiB
Plaintext

# 2014 Jan 08
#
# 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 fts5tokendata
# If SQLITE_ENABLE_FTS5 is not defined, omit this file.
ifcapable !fts5 {
finish_test
return
}
foreach_detail_mode $testprefix {
sqlite3_fts5_register_origintext db
fts5_aux_test_functions db
proc b {x} { string map [list "\0" "."] $x }
db func b b
do_execsql_test 1.0 {
CREATE VIRTUAL TABLE ft USING fts5(a, b, tokendata=1,
tokenize="origintext unicode61", detail=%DETAIL%
);
CREATE VIRTUAL TABLE vocab USING fts5vocab(ft, instance);
}
do_execsql_test 1.1 {
INSERT INTO ft(rowid, a, b) VALUES
(1, 'Pedagog Pedal Pedant', 'Peculier Day Today'),
(2, 'Pedant pedantic pecked', 'Peck Penalize Pen');
INSERT INTO ft(rowid, a, b) VALUES
(3, 'Penalty Pence Penciled', 'One Two Three'),
(4, 'Pedant Pedal Pedant', 'Peculier Day Today');
}
do_execsql_test 1.2 {
SELECT DISTINCT b(term) FROM vocab
} {
day.Day one.One peck.Peck pecked peculier.Peculier pedagog.Pedagog
pedal.Pedal pedant.Pedant pedantic pen.Pen penalize.Penalize
penalty.Penalty pence.Pence penciled.Penciled three.Three
today.Today two.Two
}
do_execsql_test 1.3.1 {
SELECT rowid FROM ft('pe*')
} {
1 2 3 4
}
do_execsql_test 1.3.2 {
SELECT rowid FROM ft('pe*') ORDER BY rowid DESC
} {
4 3 2 1
}
if {"%DETAIL%"!="none"} {
do_execsql_test 1.3.3 {
SELECT rowid FROM ft WHERE a MATCH 'pe*' ORDER BY rowid DESC
} {
4 3 2 1
}
}
do_execsql_test 1.4 {
SELECT rowid, b( fts5_test_insttoken(ft, 0, 0) ) FROM ft('pedant')
} {
1 pedant.Pedant
2 pedant.Pedant
4 pedant.Pedant
}
do_execsql_test 1.5 {
SELECT rowid, b( fts5_test_insttoken(ft, 0, 0) ) FROM ft('pe*')
} {
1 pedagog.Pedagog
2 pedant.Pedant
3 penalty.Penalty
4 pedant.Pedant
}
do_execsql_test 1.6 {
SELECT rowid, fts5_test_poslist(ft) FROM ft('pe*')
} {
1 {0.0.0 0.0.1 0.0.2 0.1.0}
2 {0.0.0 0.0.1 0.0.2 0.1.0 0.1.1 0.1.2}
3 {0.0.0 0.0.1 0.0.2}
4 {0.0.0 0.0.1 0.0.2 0.1.0}
}
}
finish_test