Rommeo Posted December 6, 2010 Share Posted December 6, 2010 My searching query does not work when I enter more than one word. For example posting that exists in my db is "red car" When I search "red" it gives me one result ( red car ) When I search "car" it gives me one result (red car ) When I search "red car" it gives me error ( could not find ) My query is like this : $select_query7="SELECT * FROM postings WHERE active = '1' AND topic LIKE '%" .$topic."%' ORDER BY addeddate DESC LIMIT ".$page.",".$count; How can I make it work with "red car" also with "red cars" Quote Link to comment https://forums.phpfreaks.com/topic/220842-searching-does-not-work-with-more-than-one-words/ Share on other sites More sharing options...
ManiacDan Posted December 6, 2010 Share Posted December 6, 2010 Look into the MATCH ... AGAINST syntax, or split the search terms into an array and do a string of (OR field LIKE '%red%' OR field LIKE '%car%') -Dan Quote Link to comment https://forums.phpfreaks.com/topic/220842-searching-does-not-work-with-more-than-one-words/#findComment-1143650 Share on other sites More sharing options...
fenway Posted December 8, 2010 Share Posted December 8, 2010 MATCH() ... AGAINST() won't help you with "red" and "car' -- the default stopword length is 4. Quote Link to comment https://forums.phpfreaks.com/topic/220842-searching-does-not-work-with-more-than-one-words/#findComment-1144487 Share on other sites More sharing options...
ManiacDan Posted December 8, 2010 Share Posted December 8, 2010 Fenway is right, that was a general observation about searching, not necessarily for your simplified example. Quote Link to comment https://forums.phpfreaks.com/topic/220842-searching-does-not-work-with-more-than-one-words/#findComment-1144507 Share on other sites More sharing options...
QuickOldCar Posted December 12, 2010 Share Posted December 12, 2010 To lower the word length edit your my.ini or my.cnf file depending what os using. So in the mysql: ft_min_word_len = 3 then restart naturally. Trying the double fields is quick solution, if wanted more advanced like exact phrases and exclude, look into doing searches in boolean mode, but would also need full text indexes. http://dev.mysql.com/doc/refman/5.1/en/fulltext-boolean.html Quote Link to comment https://forums.phpfreaks.com/topic/220842-searching-does-not-work-with-more-than-one-words/#findComment-1146091 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.