SQLite fts3:在列中搜索字符串 [英] SQLite fts3: search for a string in a column

查看:51
本文介绍了SQLite fts3:在列中搜索字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在列中搜索特定字符串?

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

我想搜索 SELECT * from email_fts WHERE email_fts MATCH 'to:"a@b.com" OR from:"c@d.com"'

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

提前致谢,

马诺伊

推荐答案

确保在 FTS 索引中创建正确的 FTS 列:

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

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

然后您可以搜索单个 FTS 列:

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:我之前的回答在 WHERE 子句中有一个 OR.显然,sqlite 不支持将 OR 查询与 MATCH 条件结合起来.上述联合有效.

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 文档在这里,这是文档中使用的示例之一.

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

http://sqlite.org/fts3.html

这篇关于SQLite fts3:在列中搜索字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆