SQLite FTS示例不起作用
发布时间:2020-12-12 18:56:25 所属栏目:百科 来源:网络整理
导读:我已经下载了最新的SQLite 3.7.15.2 shell(Win32),并尝试完全按照 http://sqlite.org/fts3.html#section_3编写的方式执行其中一个FTS示例 -- Virtual table declarationCREATE VIRTUAL TABLE docs USING fts3();-- Virtual table dataINSERT INTO docs(docid
我已经下载了最新的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仅适用于基本搜索表达式:
因此,您必须相应地重写搜索表达式: > 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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读