Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best algorithm for finding related post?

Basically this is a database and query question. How do you implement related post in your site, suppose you have this table:

+------+        +------+
+ Post +        + Tags  +
-------- N : M  --------

where post have the body and link m:n to tag. This is a very common scenario of implement tag and post.

so, How do you implement related post in your site?

like image 643
DucDigital Avatar asked Feb 10 '10 18:02

DucDigital


1 Answers

Find all the posts which overlap on at least one tag and use term frequency - inverse document frequency to weight the tags by importance, and sum the weights. Return related posts in descending order of total weight.

like image 122
Mark Byers Avatar answered Oct 04 '22 09:10

Mark Byers