以(后缀)结尾,并在SQLite FTS中使用MATCH包含字符串搜索 [英] ends with (suffix) and contains string search using MATCH in SQLite FTS

查看:1022
本文介绍了以(后缀)结尾,并在SQLite FTS中使用MATCH包含字符串搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iOS应用程序中使用SQLite FTS扩展。
它表现不错,但问题是它只匹配字符串前缀(或以关键字搜索开头)。

I am using SQLite FTS extension in my iOS application. It performs well but the problem is that it matches only string prefixes (or starts with keyword search).

即。

SELECT FROM tablename WHERE columnname MATCH'searchterm *'

SELECT FROM tablename WHERE columnname MATCH 'searchterm*'

有效,但

SELECT FROM tablename WHERE columnname MATCH'* searchterm'

SELECT FROM tablename WHERE columnname MATCH '*searchterm'

SELECT FROM tablename WHERE columnname MATCH'* searchterm *'

SELECT FROM tablename WHERE columnname MATCH '*searchterm*'

不包含。

是否有任何解决方法对此或任何使用FTS构建类似于LIKE'%searchterm%'查询的查询的方法。

Is there any workaround for this or any way to use FTS to build a query similar to "LIKE '%searchterm%'" query.

编辑:

正如Retterdesdialogs所指出的那样,以相反的顺序存储整个文本并在反向字符串上运行前缀搜索是一个可能的解决方案,结尾有/ suffix搜索问题,这是我原来的问题,但它不适用于'包含'搜索。我已经相应地更新了这个问题。

As pointed out by Retterdesdialogs, storing the entire text in reverse order and running a prefix search on reverse string is a possible solution for ends with/suffix search problem, which was my original question, but it wont work for 'contains' search. I have updated the question accordingly.

推荐答案

在我的iOS和Android应用程序中,我完全避免使用FTS搜索由于缺少后缀查询,它不支持子串匹配。

In my iOS and Android applications, I have shied away from FTS search for exactly the reason that it doesn't support substring matches due to lack of suffix queries.

解决方法似乎很复杂。

我已经使用LIKE查询,虽然性能不如MATCH满足了我的需求。

I have resorted to using LIKE queries, which while being less performant than MATCH, served my needs.

这篇关于以(后缀)结尾,并在SQLite FTS中使用MATCH包含字符串搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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