nibbrwebdevelopment Posted June 25, 2012 Share Posted June 25, 2012 I wanted to get some opionions on the best way to search for text in mysql. I have seen a lot of people using LIKE but this doesn't really do the job properly. I would add a full text index to the field i wish to search on, for example book_title. Maybe I want to search for books that are closest match to "The Big Game": SELECT *, MATCH(B.`book_title`) AGAINST('+The Big Game', IN BOOLEAN MODE ) AS RelevanceScore FROM `books` B WHERE ( MATCH(B.`book_title`) AGAINST ('+The Big Game', IN BOOLEAN MODE) || B.`book_title` LIKE '%The Big Game%' ) HAVING(RelevanceScore > 0) ORDER BY RelevanceScore DESC LIMIT 0,10 Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted June 26, 2012 Share Posted June 26, 2012 What is your question? Quote Link to comment Share on other sites More sharing options...
fenway Posted June 30, 2012 Share Posted June 30, 2012 Sphinx is one of the better choices. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.