Just wanted to know how you would do it.
I have a webservice that permits me to complete an user address while he’s writing it.
When the suggestions are shown, i’d like the part of the suggestion label that match the user input to be surrounded with bold tags.
I want the “matching” to be clever, and not just a simple/replace, since the WS we use is clever too but i don’t have that code).
For exemple:
Input: 3 OxFôr sTrE
Ws result: 3 Oxford Street
Formatted: <b>3 Oxford Stre</b>et
Formatted: [bold]3 Oxford Stre[/bold]et
I can do it in JS or Java.
I’d rather do it in JS but with Java perhaps Lucene can help?
Do you see how it can be handled?
Index your Text using NGrams using a search engine or a custom data structure. I am implementing Auto Recommendation stuff by indexing around 1 billion query words using NGrams & then while displaying I sort them as per frequency of each typed query. Lucene/Solr can help you here. Highlighting stuff (as you asked) will be enclosed in tags by default if you use Lucene/Solr and you can also exploit ngram indexing feature provided by Lucene/Solr
LinkedIn Engineering recently open sourced Cleo (the open source technology behind LinkedIn’s typeahead search) : Link.
Great stuff by LinkedIn. Check out for clever matching and highlighting stuff as desired by you