I enabled fts in sqlite for iphone and tried this and works, although very slow:
SELECT field FROM table_fts WHERE replace(replace(replace(replace(replace(lower(field), 'á','a'),'é','e'),'í','i'),'ó','o'),'ú','u') LIKE replace(replace(replace(replace(replace(lower('%string%'), 'á','a'),'é','e'),'í','i'),'ó','o'),'ú','u')
But it does not work when I want to use MATCH, it does not bring me results and there is no error
SELECT field FROM table_fts WHERE replace(replace(replace(replace(replace(lower(field), 'á','a'),'é','e'),'í','i'),'ó','o'),'ú','u') MATCH replace(replace(replace(replace(replace(lower('string'), 'á','a'),'é','e'),'í','i'),'ó','o'),'ú','u')
Is there any error or is there any other approach where I can make a tilde insensitive search?. I looked answers in the web with no success.
Two approaches:
First, you can violate normal-form and add columns to your table containing ASCII-only representation of your searchable fields. Furthermore, before doing a search against this secondary search column, you also remove international characters from the string that being searched for, too (that way you’re looking for ASCII-only string in a field with the ASCII-only representation).
By the way, if you want a more general purpose conversion of international characters with ASCII, you can try something like:
Second, you could presumably use
sqlite3_create_function()to write your own function (that presumably invokes a permutation of the above) that you can use right in your SQL statements themselves. See the SQLite documentation.Update:
By the way, given that you’re doing FTS, the
sqlite3_create_function()approach is probably not possible, but it strikes me that you could either do FTS on the field containing the ASCII-only string, or write your own tokenizer that does something along those lines.