• Advertisement

Archived

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

Writing a search engine in PHP and MySQL

This topic is 4969 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to write a small search engine for a site and it needs to be in PHP and MySQL (that is all the server will serve). I am interested in learning how google can take a mis-spelled word and say "did you mean _____?" and other methods of returning results if the user did not spell the name of an item correctly. Does anyone have any good tips or tricks, perhaps a good link they can send me to? Cheers edit: Can a mod please move this thread to general programming? MindEngine (C++) | E-Commerce Business Architecture (ASP.NET / C#) [edited by - neurokaotix on June 10, 2004 8:05:56 PM]

Share this post


Link to post
Share on other sites
Advertisement
If you where crazy enough maybe you could create a script to search a mySQL database for the words. Except that is pretty much insanity.

/-09x2

[edited by - 09x2 on June 10, 2004 9:10:23 PM]

Share this post


Link to post
Share on other sites
What if it only had to search for a small set of words? This is for a furniture site, and there are only so many things you would look for on a furniture site. Would it be insane to check each word against a list of 500-1000 words to see if they are similar?

MindEngine (C++) | E-Commerce Business Architecture (ASP.NET / C#)

[edited by - neurokaotix on June 10, 2004 9:14:09 PM]

Share this post


Link to post
Share on other sites
Just 500-1000. That would be fine. Heh, I thought you meant the whole English language.

Now on how to do the script.

If they had two words, say Royal King, you would more likely do a search with a SQL looking for all the words. That fails, you search for just the beginning, then just the end.

Edit Note: If it has multiple words search for each of them.

/-09x2

[edited by - 09x2 on June 10, 2004 9:25:35 PM]

Share this post


Link to post
Share on other sites
So if the user searches for "Oak Dresser" and the search returns no results for oak dressers, it would search for "Oak" and then "Dresser," correct?

How would I tie that into the spell checking? Would I spell check the words to begin with or only after one fails, or perhaps when both fail?

MindEngine (C++) | E-Commerce Business Architecture (ASP.NET / C#)

[edited by - neurokaotix on June 10, 2004 9:33:04 PM]

Share this post


Link to post
Share on other sites
Yea.

WHERE N='$name'
WHERE N LIKE '$part%'
WHERE N LINE '%$part'
WHERE N LIKE '%$part%'
Just encase you forgot the SQL, like I sometimes do.

If you can get your hands on a spell checker script, or can get your hands on that extension (I believe it is in the default install, at least PHP 5 RC3 has it, so it might be included.) do it after all of the searches because some furniture have weird names. If not, throw a error because they can't spell and shouldn't be able to buy anything.

/-09x2

[edited by - 09x2 on June 10, 2004 11:22:36 PM]

Share this post


Link to post
Share on other sites

  • Advertisement