Jump to content


Photo

Similar Item Search - percentage match


  • Please log in to reply
3 replies to this topic

#1 jwwceo

jwwceo
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts

Posted 05 September 2006 - 06:08 PM

I have a website with a few hunded items, which could grow to a few thousand. One of the features I am trying to code is a button that will offer similar selections. All of my products are classified with keywords and colors. So when the search is run, it will check to see how many keywords and color matches there are and then returns recommendations, ideally with a percentage match, like say for example, a 93% match. I have seen these before and I really like the idea.

Does anyone have any tips on the logic/ SQL query structure to do this... I can't wrap my head around the best way to do this...



#2 paul2463

paul2463
  • Members
  • PipPipPip
  • Advanced Member
  • 955 posts
  • LocationUK

Posted 05 September 2006 - 06:35 PM

percentages are done from what you are searching for so if you search on "hard" "wooden" "curved" "smooth" and "yellow"
run a count on the record sets for the amount of matches to the list put in
5 search words put in,  4 search words returned in the recordset row 1 4/5 = 80% match
5 search words put in,  2 search words returned in the recordset row 2 2/5 = 40% match

iterate over the recordset percentages and then order them highest first

so if you had a "hard" "wooden" "curved" "smooth" and "yellow" in thye databse it would get 5 words in , 5 words out = 5/5=100%
you cannot affect the past but you can ruin a perfectly good present by worrying about the future

*********************************************************************
The <A HREF="http://www.php.net/d...php">MANUAL</A> is actually a useful resource

#3 paul2463

paul2463
  • Members
  • PipPipPip
  • Advanced Member
  • 955 posts
  • LocationUK

Posted 05 September 2006 - 06:48 PM

also you could use a thesaurus....any keyword that is put in, you could run it through and get all the synonyms for it and search on those to, any returns with synonyms gets a penalty on the maths for % mark
you cannot affect the past but you can ruin a perfectly good present by worrying about the future

*********************************************************************
The <A HREF="http://www.php.net/d...php">MANUAL</A> is actually a useful resource

#4 jwwceo

jwwceo
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts

Posted 05 September 2006 - 06:58 PM

I'm having trouble with the SQl statements... if I have 3 tables... one for items, one for keywords, and one for matching the two...

how would I structure the SQL queries?
How do I pass the info over to the results page, a big long GET?






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users