带有全文搜索的sqlite在查询空间时找不到结果 [英] sqlite with full text search doesn't find results when space in query
问题描述
我在玩 notmuch-abook ,它使用sqlite3来存储名称和电子邮件地址。 sqlite表使用全文搜索,由以下内容创建:
CREATE VIRTUAL TABLE AddressBook USING fts4(Name,Address);
我有名为Hamish,Hamish D和Hamish Downer的参赛作品。查询
select * from addressbook where addressbook match'hamish';
全部找到。然而
select * from addressbook where addressbook match'hamish d';
仅查找名称为Hamish D但不是 em>不会找到名称为Hamish Downer的条目。我可以得到我期望的结果:
select * from addressbook where name like'hamish d%';
但是我想使用匹配版本来匹配两列。任何想法这里发生了什么?或者如何让匹配按照我的意愿工作?
解决方案阅读 查找记录那包含两个词 要搜索前缀,请使用 I'm playing with notmuch-abook which uses sqlite3 to store names and email addresses. The sqlite table uses full text search, being created by: I have entries for myself with names "Hamish", "Hamish D" and "Hamish Downer". The query Finds them all. However Finds only the entries with the exact name "Hamish D" but does not find the entries with name "Hamish Downer". I can get what I expect with: But I'd like to use the match version to match across both columns. Any idea what's going on here? Or how to get match to work as I want? Read the documentation. The query finds records that containt the two words To search for prefixes, use
这篇关于带有全文搜索的sqlite在查询空间时找不到结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
<$> p $ p $ ... addressbook match'hamish d'
hamish
和 d
。您可能想要搜索 hamish d
这个短语,您可以使用
... addressbook match'hamish d'
*
:
... addressbook match'hamish d * '
CREATE VIRTUAL TABLE AddressBook USING fts4(Name, Address);
select * from addressbook where addressbook match 'hamish';
select * from addressbook where addressbook match 'hamish d';
select * from addressbook where name like 'hamish d%';
... addressbook match 'hamish d'
hamish
and d
. You probably want to search for the phrase hamish d
instead, which you can do with... addressbook match '"hamish d"'
*
:... addressbook match '"hamish d*"'