SQLite FTS4 search with special characters

2019-04-08 21:05发布

问题:

I have an Android app which searches for data in an SQLite database with FTS4 virtual tables. It works fine, but when the data inside the tables contain special characters (like 'á', 'é', 'í', 'ó', 'ú' or 'ñ') the SQLite MATCH function gives no results. I'm lost at this point. Thanks.

回答1:

Attention: default tokenizer is really poor. To get good results you should implement a custom tokenizer. The path isn't so simple:

  • find the tokenizer (with stemmer?) that should fit your need, or develop it
  • glue it with sqlite.c sources
  • glue a JNI interface to wrap the native library so it will be accessible from the dalvik VM
  • use NDK to compile sqlite.c from scratch and prepare a dynamic library for Android

Here in stackoverflow you should find some good posts to start learning how to do that.

Look at these projects to get some good starting point:

  • sqlite4java
  • sqlcipher