SQLite FTS3 simulate LIKE somestring%

拟墨画扇 提交于 2019-11-29 20:38:56

问题


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

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 *"';

, then parse the offsets string in code.

Are there any better options?


回答1:


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



来源:https://stackoverflow.com/questions/2734828/sqlite-fts3-simulate-like-somestring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!