-
Notifications
You must be signed in to change notification settings - Fork 13
/
test.sql
25 lines (25 loc) · 1.12 KB
/
test.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
select load_extension('./libtrilite.so');
create virtual table trg using trilite;
-- TriLite current creates two underlying tables
.tables
-- Wrap insertions into a transaction (not strictly required)
BEGIN TRANSACTION;
insert into trg (id, text) VALUES (1, 'abcd');
insert into trg (id, text) VALUES (2, 'bcde');
insert into trg (id, text) VALUES (3, 'bcdef');
insert into trg (id, text) VALUES (4, 'abc');
insert into trg (id, text) VALUES (4, 'abCd');
-- Note that we can only query data after we've committed
-- This is just a detail left out so far.
COMMIT TRANSACTION;
-- See we have content
select * from trg_content;
-- We also have doclists, Note the trigram is encoded as integer
select trigram, length(doclist), hex(doclist) from trg_index;
-- Now, let's select something, -extents: tells, to generate extents when matching
select *, hex(extents(contents)) from trg WHERE contents MATCH 'substr-extents:abc' and contents MATCH 'regexp-extents:bcd';
-- Okay let's try isubstr
select "Testing isubstr:";
select * from trg WHERE contents MATCH 'isubstr-extents:aBc';
;
select text from trg where contents MATCH 'substr-extents:' AND id = 1;