Jump to content

Similar Item Search - percentage match


jwwceo

Recommended Posts

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...

Link to comment
https://forums.phpfreaks.com/topic/19794-similar-item-search-percentage-match/
Share on other sites

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%

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.