开发者

SQLite fts3: search for a string in a column

开发者 https://www.devze.com 2022-12-26 06:02 出处:网络
Is there any way to search for a particular string in a column? I want to search like SELECT * from email_fts WHERE email_fts MATCH \'to:\"a@b.开发者_Go百科com\" OR from:\"c@d.com\"\'

Is there any way to search for a particular string in a column?

I want to search like SELECT * from email_fts WHERE email_fts MATCH 'to:"a@b.开发者_Go百科com" OR from:"c@d.com"'

Thanks in advance,

Manoj


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

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

And then you can search 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 an OR in the WHERE clause. Apparently sqlite doesn't support combining OR queries with MATCH conditions. The above union works.

FTS docs are here, this is one of the examples used in the docs.

http://sqlite.org/fts3.html

0

精彩评论

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

关注公众号