SQLite fts3: finding a row in a column

Is there a way to find a specific row in a column?

I want to search as SELECT * from email_fts WHERE email_fts MATCH 'to: " a@b.com " OR from: " c@d.com "

Thanks in advance,

Manozh

+4
source share
1 answer

Make sure you create the correct FTS columns in the FTS index:

CREATE VIRTUAL TABLE email_fts USING fts3(subject, body, "to", "from"); 

And then you can search for individual FTS columns:

 SELECT rowid FROM email_fts WHERE "to" MATCH ' a@b.com ' UNION SELECT rowid FROM email_fts WHERE "from" MATCH ' c@d.com ' 

EDIT: my previous answer had OR in a WHERE . Apparently sqlite does not support combining OR queries with MATCH conditions. The above union works.

The FTS docs are here; this is one example used in the docs.

http://sqlite.org/fts3.html

+6
source

Source: https://habr.com/ru/post/1306671/


All Articles