我已经下载了最新的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.
检查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