Searching -- Like ebay

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Searching -- Like ebay

Post by tecktalkcm0391 »

How does ebay do the search for your category where if you type hello in it returns:
Categories: select up to two for your listing % item match


Collectibles > Animation Art, Characters > Japanese, Anime > Sanrio, Hello Kitty > Hello Kitty > Other Items 36%

Collectibles > Animation Art, Characters > Japanese, Anime > Other Japanese, Anime 9%

Music > CDs 8%

Toys & Hobbies > TV, Movie, Character Toys > Hello Kitty > Other 9%

Clothing, Shoes & Accessories > Women's Accessories, Handbags > Handbags, Bags 6%

Collectibles > Animation Art, Characters > Animation Characters > Hello Kitty 6%

DVDs & Movies > DVD & HD DVD 5%

Books > Children's Books 4%
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

By the looks of your results it would appear that it categories containing the keyword your searching for are weighted higher.
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

Ok, well how could I do something like that?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

search engines are complicated beasts man... VERY complicated. (Yes I realize this doesn't really help you)

EDIT: Oh and are you PM and AIM links hotlines?
Ward
Forum Commoner
Posts: 74
Joined: Thu Jul 13, 2006 10:01 am

Post by Ward »

I dont think it could be done in pure SQL. This is off the top of my head, but heres what I'm thinking:

1. Search for items containing the keyword searched for

2. Count the total number of keywords found in all results

3. Divide each items keyword count by the total keyword count, to find it's percentage.

This would be a very simple method for sorting by relevancy, and I'm sure ebay has a much more complicated method.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I think there system uses an algorithm designed to weigh certain words against other words. They are graded, then reuslts are returned in order of grade. I am not sure this is a SQL capable task.
Post Reply