SQLite的FTS3模拟LIKE somestring% [英] SQLite FTS3 simulate LIKE somestring%

查看:216
本文介绍了SQLite的FTS3模拟LIKE somestring%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一本字典应用程序,需要做的通常的文字提示,同时打字。

I'm writing a dictionary app and need to do the usual word suggesting while typing.

LIKE somestring%是相当缓慢的(〜在〜10万行的表1300ms),所以我转向FTS3。

LIKE somestring% is rather slow (~1300ms on a ~100k row table) so I've turned to FTS3.

但问题是,我还没有发现从字符串的开头来搜索一个理智的方式。
现在我执行查询像

Problem is, I haven't found a sane way to search from the beginning of a string.
Now I'm performing a query like

SELECT word, offsets(entries) FROM entries WHERE word MATCH '"chicken *"';

,然后解析偏移字符串code。

, then parse the offsets string in code.

有没有更好的选择吗?

推荐答案

,请务必设置索引字段和使用

Yes, make sure to set the index on field word and use

word >= 'chicken ' AND word < 'chicken z'

替换LIKE或火柴或GLOB

instead of LIKE or MATCH or GLOB

这篇关于SQLite的FTS3模拟LIKE somestring%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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