0

I am looking to implement a 'youtube related videos' style related content system.

I have 5 tags/keywords for each of my pages, a title and a description. I would like to display links to the two most similar pages.

I am guessing a mysql query based around order by relevance.

many thanks.

4

2 回答 2

2

you can break up the title, description, keywords into tokens and then do a full text search in mysql on those keywords and order by relevance.

select * from article where match(title, description, keywords)
  against ('word1 word2 word3 word4' in boolean mode)
  order by relevance desc

http://dev.mysql.com/doc/refman/5.0/en/fulltext-boolean.html

于 2010-01-11T00:34:34.850 回答
1

First, the keywords should be indexed so that it can be accessed faster.

Then you can do a fulltext search: http://en.wikipedia.org/wiki/Full_text_search Or, you could do a LIKE query: http://www.w3schools.com/SQL/sql_like.asp

Then, with those results, you just make the list of the related items.

于 2010-01-11T00:33:02.060 回答