Click here to Skip to main content
15,911,762 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, how I can can organize insensitive search using SQLite ? It is necessary to set up non-fulltext search so I can search for parts of words. Now the program is based on System.Data.SQLite.dll. It use Like operator and operator override Lower (), because standard function can not work with non-latin characters, received a request "select * from myTable where Lower (myColumn) Like %text%". It works fine, but the search takes a long time and on the basis of a total of approximately 20-50 thousand strings can be searched 5 seconds. Tell me how you can still set up a case-insensitive search on SQLite to shorten the time of the request? Or maybe someone will share the collected working library with support for the ICU?

What I have tried:

I find an article that is written about the ICU, I need to use the SQLite library for on normal non_latin characters to search built-in ICU. On the official website I found the default Sqlite3.dll library but it also does not support the non-Latin characters. I found a bunch of SQLite3.dll libraries with support it with built the ICU, but no one could not connect when you try to access it hangs the application.
Posted
Updated 5-Nov-16 4:10am

1 solution

What I would suggest for your case would be to create a case-insensitive index on your search field, and then force the select to use that index in its search.
SQL
CREATE INDEX iCaseInsensitive ON myTable(myColumn COLLATE NOCASE);
...
SELECT * FROM myTable INDEXED BY iCaseInsensitive WHERE myColumn <expr>;

Note that with this system, if you are putting conditions on other columns, you will either have to add those columns to the index, or use a JOIN.
Another possibility I just thought of, if the COLLATE NOCASE does not work with your character set, create the index from the column already converted to lower case
SQL
CREATE INDEX iCaseInsensitive ON myTable(Lower(myColumn));
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900