2013-08-05 69 views
1

我寫一個濾波算法,需要用戶輸入的陣列,像Rails 3的搜索算法的實現

@keywords = [['undergrad','grad'],['SAT', 'GPA'], ['Stanford']] 

和查詢表,例如,在我的數據庫表中的視頻。表格中有一個字符串字段,其中包含由逗號分隔的一對標籤。

的邏輯是:

In all videos, if the tags include "undergrad", "grad", returned those videos; 
In the returned videos, if the tags include "SAT", "GPA", returned those videos; 
In the returned videos, if the tags include "Stanford", returned those videos; 

上實現它on Rails的任何幫助嗎?

+0

你是如何實現標記?你使用的是類似https://github.com/mbleigh/acts-as-taggable-on的東西,還是隻是你的視頻表中的字段? – Cyrus

+0

因此,標籤是一個字段,包含由逗號分隔的單詞,e.x,「undergrad,GPA」 –

+0

直接存儲在您的視頻模型中? – Cyrus

回答