我有關於sqlite的FTS的問題。SQlite全文搜索(FTS)?
創建表:
CREATE VIRTUAL TABLE mail USING fts3(subject, body);
插入演示數據
INSERT INTO mail(docid, subject, body)
VALUES(1, 'software feedback' 'found it too slow');
INSERT INTO mail(docid, subject, body)
VALUES(2, 'software feedback', 'no feedback');
INSERT INTO mail(docid, subject, body)
VALUES(3, 'slow lunch order', 'was a software problem');
代碼搜索查詢
SELECT *
FROM mail
WHERE subject MATCH 'software*'; ==> Selects rows 1 and 2
SELECT * FROM mail WHERE body MATCH 'feedback'; ==> Selects row 2
SELECT * FROM mail WHERE mail MATCH 'software*'; ==> Selects rows 1, 2 and 3
SELECT * FROM mail WHERE mail MATCH 'slow'; ==> Selects rows 1 and 3
然而,當我想以一個詞來搜索文本。例如:我想搜索的任何單詞包含字符 「o」:
例:
SELECT *
FROM mail
WHERE mail MATCH 'o';
我沒有得到任何結果...
誰能幫助我?
FTS沒有使用搜索模式的文本列。你描述的是一個簡單的'LIKE'語句。 –