Sqlite FTS3/4 only NOT search

351 views Asked by At

How to select all rows except unneeded from SQLite FTS3 or FTS4 table?

select * from table where table match 'column:NOT phrase'
select * from table where table match 'column:-phrase'
select * from table where table match 'column:* NOT phrase'

not working as expected.

1

There are 1 answers

0
CL. On

This is not possible with either NOT or -, because the negation must not be the only operator in the FTS query.

You have to search for the phrase, and exclude those rows from the result with normal SQL:

SELECT ...
FROM MyTable
WHERE ID NOT IN (SELECT docid
                 FROM MyTableFTS
                 WHERE MyTableFTS MATCH 'phrase');