Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.