I already have an integrated search based on the official Android documentation and I use the following schema and SQLite query:
CREATE VIRTUAL TABLE Search USING FTS3 ( _id, name, location ); select * from Search where name MATCH ?
I am wondering how can I extend it? to allow the following:
Say I have a few names:
- My fancy element
- My secret element
- Paragraph 1
- Your Unusual Item.
When the user enters blah in the search field, the search results show:
my- My Fancy Element
- My secret element
mfifan item , fanit , fit- My fan cy he em
- Your fan cy he em
it , item , im , itm- My fancy i te m
- My secret I te m
- I te m # 1
- Your fancy I te m
The results should be ranked based on how good the match is, for example, if the letters are further away, they should be rated lower than the exact match, for example, for mfi : โMy Unusual Itemโ should take last place and โMFI thingyโ should take first place (if there was such an item).
Note. my min SDK is API level 10, which means that it must run SQLite 3.6.22 .
Similar functionality can be found mainly in the IDE:
android sqlite search full-text-search fts3
TWiStErRob
source share