Page 1 of 1

need a code

Posted: Tue Aug 10, 2004 2:51 am
by sadafrasheed
hi!!
i need a code that can search database for keywords. the special thing is that if user makes a typing mistake,, the code should detect it and should search the database for actual word...
i am sure it must be some where on net but dont have time to seach. if some one knows where to find it plz give me the link. its urgent!!
bye

Posted: Tue Aug 10, 2004 3:19 am
by CoderGoblin
Sounds like you need to look at the php command levenshtein and it's "see also links"
http://www.php.net/manual/en/function.levenshtein.php. Depends on what you need to search for. If searching for a specific word in a paragraph within the database it could take a long time to process. The question you need to ask yourself is how to detect when a typing error has occured.

A lot of companies spend a fortune on search algorithms to solve this problem and produce results in reasonable timeframes, therefore they do not give out their code.

Posted: Tue Aug 10, 2004 4:32 am
by patrikG
For quick'n dirty search-functionality I'd use MySQL's fulltext. Check the argument "WITH QUERY EXPANSION" - could come in handy, but I'd do some filtering with PHP as CoderGoblin suggested.