I have a phonebook program which essentially takes a search and goes through a data base to find matches and displays the results. I am using full text searching but my problem is that if I search for an exact name, The program will display everything that is close to the search BUT the exact name.
eg: If i search “bob smith” The results will display everything close to bob smith… such as “bob smithe, rob smith, etc…” but will not display “bob smith”
If i search “rob smith”, bob smith will be displayed in the result but not “rob smith”.
I finally solved the problem bluntly by using LIKE and also searching by FULL TEXT… apostrophes gave me some trouble but i solved it using an str_replace fragment… Thank you everyone for the help!
The only reason I used the full text search was because not only do i need to search through the names, but also certain “tags” that are associated with each name… such as “painting, construction etc” this is all part of the yellow pages section.
Im sorry for reviving the thread but I am still stuck. If i search “IN BOOLEAN MODE” I does find an exact match (Plus others) but does not sort by relevance… But if I search without boolean mode, It doesn’t find an exact match BUT it does sort by relevance desc.
Thanks! I used % and boolean mode and it seems work in finding the proper match words. Though now I have the problem that it is displaying alphabetically and not by relevance. Is there a way to ORDER BY relevance?
I tried something like:
$result = MySQL_query(“SELECT *,MATCH (Class,Name)AGAINST (‘$name%’) as Relevance FROM $table WHERE MATCH (Class,Name)AGAINST ('$name%'IN BOOLEAN MODE) HAVING Relevance > 0.2 Order by Relevance Desc”);