cb154 Posted July 20, 2010 Share Posted July 20, 2010 Hi, I have written a search engine for my site which is Wine related. no the question is around using full text searches. User types in a certain wine say Chateau x de b and it returns that at the top as I order by ranking however it also returns all the wines in my db that have Chateau in them as you can imagine that is pretty much all of them. I also want to stop people typing just Chateau in the search box as they will also slow it down. Is there a way of matching against a seperate list of keywords to ignore ? Quote Link to comment https://forums.phpfreaks.com/topic/208301-full-text-searches/ Share on other sites More sharing options...
ngreenwood6 Posted July 21, 2010 Share Posted July 21, 2010 I dont know if I am misunderstanding your question or what but from what it looks like to me you dont need to do this throught mysql you can do it through php. You could create an array of words that you didnt want to be included in the search. Then you could just do a str_replace(or str_ireplace - is case insensitive) and remove those words. For example: //users search $data = "Chateau wine another x de keyword"; //search and replace $search = array("Chateau","another","keyword"); $replace = ""; //run the replace $data = str_replace($search,$replace,$data); //users search after would be "wine x de" So if you look at the code that I provided it will just remove the keywords that you dont want to be included. You can add as many as you want and you can also make the replace an array and tell it to replace the keywords with other words if you wanted to. Please let me know if I was wrong in your question. Quote Link to comment https://forums.phpfreaks.com/topic/208301-full-text-searches/#findComment-1088918 Share on other sites More sharing options...
cb154 Posted July 21, 2010 Author Share Posted July 21, 2010 that makes sense. was just me over complicating things Quote Link to comment https://forums.phpfreaks.com/topic/208301-full-text-searches/#findComment-1089174 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.