开发者

SQLite FTS3 simulate LIKE somestring%

开发者 https://www.devze.com 2022-12-28 08:19 出处:网络
I\'m writing a dictionary app and need to do the usual word suggesting while typing. LIKE somestring% is rather slow (~1300ms o开发者_运维百科n a ~100k row table) so I\'ve turned to FTS3.

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

LIKE somestring% is rather slow (~1300ms o开发者_运维百科n 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 *"';

, then parse the offsets string in code.

Are there any better options?


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

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

instead of LIKE or MATCH or GLOB

0

精彩评论

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