验证 sqlite FTS(全文搜索)语法,以及如何执行单个术语 NOT 搜索
有没有办法确定发送到 sqlite 中 fts3 表的 MATCH 查询是否有效?目前,在尝试运行该表达式之前,我无法确定该表达式是否无效,这使得它有点棘手。我想在尝试运行它之前向用户报告语法无效。
我正在将 sqlite 与 C api 一起使用。
此外,使用表达式“NOT”进行搜索将失败,并显示“SQLlite 逻辑/数据库错误”。谷歌搜索似乎表明这样的查询是无效的。是否有正确的语法来执行该操作?我本质上是想找到不包含该术语的条目。或者我是否必须重新使用 LIKE 并进行顺序扫描而不使用 FTS?
Is there a way to determine if a MATCH query sent to an fts3 table in sqlite is valid? Currently, I don't find out if the expression is invalid until I try to run it, which makes it a little tricky. I'd like to report to the user that the syntax is invalid before even trying to run it.
I'm using sqlite with the C api.
Additionally, doing a search with the expression "NOT " will fail with a "SQLlite logic/database error". Googling seems to indicate that such a query is invalid. Is there a correct syntax to do the operation? I'm essentially trying to find entries that do NOT contain that term. Or do I have to drop back down to using LIKE and do a sequential scan and not use FTS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来现在最简单的方法是创建一个没有行的单独的 FTS 表,并对其执行查询。由于表中没有数据,因此会立即执行,并且如果查询语法不正确,则会报告并出错。
Looks like the simplest way right now is to create a separate FTS table with no rows, and execute the query against it. It will be immediate since there's no data in the table, and will report and error if the query syntax is incorrect.