开发者

Verifying sqlite FTS (Full Text Search) syntax, and how to do a single term NOT search

开发者 https://www.devze.com 2022-12-18 13:59 出处:网络
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.

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 a开发者_如何学编程nd not use 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消