SQlite3 fts negate search

有些话、适合烂在心里 提交于 2019-12-24 11:45:58

问题


Hi and thanks for looking!

I'm searching for articles which contain certain strings with full text search, something like this:

SELECT * FROM Articles_fts WHERE body MATCH 'monkey OR banana OR "hungry gorilla"';

My real search is much longer (22 terms) and probably not the smartest way of doing this but it's working so no problems there.

What I need help with... Now I want to return the OPPOSITE of what this search returns. In other words I want all the articles that don't contain monkey, banana, or "hungry gorilla".

Thanks very much in advance!


回答1:


NOT is available only when SQLite was compiled with the enhanced FTS query syntax enabled.

Otherwise, you can use SQL set operations to negate the result:

SELECT *
FROM Articles
WHERE id NOT IN (SELECT docid
                 FROM Articles_fts
                 WHERE body MATCH '...')


来源:https://stackoverflow.com/questions/28743932/sqlite3-fts-negate-search

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!