building a better search

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
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

building a better search

Post by Unipus »

I'm soon going to need to rewrite/enhance a search engine for a site. What I need it to do is give results priority based on the number of times they were successfully searched for. In other words, if 50 people go searching for "Canned Pork," 30 of them look at the results and click on "Ye Olde Canned Pork," 10 of them click on "Canned Pork MX-7", and the rest click on an assortment of other results, the engine needs to know to provide "Ye Olde Canned Pork" as the first search result every time. Of course I mean this should be dynamic and automatic, so that if MX-7 Canned Pork starts to become more popular as a result, the search engine makes that the #1 result. This is similar to what Google does.

I have no idea how to do it, really. Obviously, there's a table that's tracking searches somewhere, but how do I track the results that people pick first when they do a search, and then match it to what they searched for, and then use that data to influence future search results?
murph
Forum Commoner
Posts: 29
Joined: Fri Oct 03, 2003 1:28 pm
Location: washington

Post by murph »

make a new field on the table where the products are, name it hits. When the user searches for something and the results come up, order them by hits, when the user clicks to get more info send him to a site that will update the hits for that item. Then redirect to the info on that product. Not to hard...
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post by Unipus »

Well, it's not quite that simple. That would produce a whole slew of unwanted result preferencing, I think. I need to tie the search terms used to the results produced, and weight them that way, somehow.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

add a table
create table result_prefs(
terms text NOT NULL,
website tinytext NOT NULL,
hits int NOT NULL default '0',
FULLTEXT terms ( terms )
) TYPE=MyISAM;


if the new terms are a subset of previous terms, add all the hits for that site together to use the ranking

that gives you weight based on what others with SIMILAR searches go for. if you can also make the comob of the terms/website unique then i'd do that. i've never tried so i'm not sure.

then you can search for where the terms and website are equal and add one to the hits when someone clicks the link
Post Reply