php - How to find similar stories based on keyword matching? -


I have a table, story_keywords containing the following columns, which are keywords matched with a special story: id, story_id The keyword_id

what I want to do now captures any story that shares at least two keywords with the primary story, for the first loop to get all the stories for today I get the output I am doing

// Get a list of keyword_ids for the primary story

// Get a list of all the stories, and their keyword_ids, which match when I get through the primary story keyword_ids From the cycle

But I'm stuck, I can not understand it rationally for any reason, can someone give advice? I'm not sure what other information I can provide to make it more clear

I can get a list of stories that match the 1 keyword from elementary stories, but I To produce a kind of story, I want to match at least two keywords.

You can use the code> keyword_id IN (...) stories which will be your primary story Area to find stories associated with the same highly relevant that share the same keywords, you want to fix the results based on the number of keywords in the results order.

something like about :

  select story_id, COUNT (story_id) AS from relevance story_keywords WHERE keyword_id IN (...) group by story_id Relevance of & gt; 2 ORDER Relevance DeSc LIMIT 5  

You probably want to add another WHERE section to exclude the original story_id .

>

Comments