Writing a search engine in PHP and MySQL

Started by
6 comments, last by neurokaotix 19 years, 10 months ago
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]
Advertisement
PHP Pspell Extension

/-09x2
Thank you for replying, unfortunately I do not have access to the server to where I would be able to reinstall the PHP installation, anything I do needs to be done by the scripts themselves.

MindEngine (C++) | E-Commerce Business Architecture (ASP.NET / C#)
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]
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]
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]
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]
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]

This topic is closed to new replies.

Advertisement