gpt4 book ai didi

ruby-on-rails-3 - Rails 3搜索算法实现

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:25:05 26 4
gpt4 key购买 nike

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

@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 上实现它有什么帮助吗?

最佳答案

如果你使用的是 Postgres,你可以这样做 http://www.postgresql.org/docs/current/static/functions-matching.html在你的 where 语句中。

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

关于ruby-on-rails-3 - Rails 3搜索算法实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18067540/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com