1

我正在编写一个过滤算法,它将用户输入作为数组,比如

@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;

在 Rails 上实现它有什么帮助吗?

4

1 回答 1

0

如果您使用 Postgres,您可以在 where 语句中执行类似http://www.postgresql.org/docs/current/static/functions-matching.html的操作。

或 MySQL https://dev.mysql.com/doc/refman/5.0/en/pattern-matching.html

于 2013-08-06T02:16:09.780 回答