using sqlite (with FTS) on Android

后端 未结 1 1417
难免孤独
难免孤独 2021-01-07 02:25

I am using sqlite FTS3 database, with my Android application.

   public Cursor getWordMatches(String query, String[] columns) {
        String selection = KE         


        
1条回答
  •  醉梦人生
    2021-01-07 02:51

    Full text search tables should always use MATCH and not LIKE, because a LIKE query performs a full scan of the table which defeats the purpose of creating the FTS table in the first place.

    To solve your problem, trying using a tokenizer other than the default when creating your fts table:

    -- Create a table using the simple tokenizer.
    CREATE VIRTUAL TABLE simple USING fts3(tokenize=porter);
    

    By default, SQLite uses a simple tokenizer which may be generating the matches you don't want. Switch to the porter tokenizer and see what happens. Worst case, you can implement your own custom tokenizer. See the SQLite documentation for further info.

    0 讨论(0)
提交回复
热议问题