Jump to content

Full text searches


cb154

Recommended Posts

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 ?

Link to comment
https://forums.phpfreaks.com/topic/208301-full-text-searches/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/208301-full-text-searches/#findComment-1088918
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.