SQLite FTS示例不起作用

我已经下载了最新的sqlite 3.7.15.2 shell(Win32),并尝试完全按照 http://sqlite.org/fts3.html#section_3编写的方式执行其中一个FTS示例

-- Virtual table declaration
CREATE VIRTUAL TABLE docs USING fts3();

-- Virtual table data
INSERT INTO docs(docid,content) VALUES(1,'a database is a software system');
INSERT INTO docs(docid,content) VALUES(2,'sqlite is a software system');
INSERT INTO docs(docid,content) VALUES(3,'sqlite is a database');

-- Return the set of documents that contain the term "sqlite",and the
-- term "database". This query will return the document with docid 3 only.
SELECT * FROM docs WHERE docs MATCH 'sqlite AND database';

但是尽管有最后的评论SELECT导致了空集.它是sqlite中的错误还是过时的文档? (那是什么语法?).

对我来说最重要的是查询

SELECT * FROM docs WHERE docs MATCH '(database OR sqlite) NEAR/5 system';

在我的应用程序中我需要的那种查询也不起作用.有没有其他方法可以写它以便它可以工作?

解决方法

文档中的示例使用 enhanced query syntax.
检查PRAGMA compile_options;包括ENABLE_FTS3_PARENTHESIS.

您的NEAR查询不起作用不是编译选项的问题:

> SELECT * FROM docs WHERE docs MATCH '(database OR sqlite) NEAR/5 system';
Error: malformed MATCH expression: [(database OR sqlite) NEAR/5 system]

问题是,根据文档,NEAR仅适用于基本搜索表达式:

A NEAR query is specified by putting the keyword “NEAR” between two phrase,term or prefix queries.

因此,您必须相应地重写搜索表达式:

> SELECT * FROM docs WHERE docs MATCH '(database NEAR/5 system) OR (sqlite NEAR/5 system)';
a database is a software system
sqlite is a software system

相关文章

SQLite架构简单,又有Json计算能力,有时会承担Json文件/RES...
使用Python操作内置数据库SQLite以及MySQL数据库。
破解微信数据库密码,用python导出微信聊天记录
(Unity)SQLite 是一个软件库,实现了自给自足的、无服务器...
安卓开发,利用SQLite实现登陆注册功能