这需要全文搜索还是可以使用方法?
我有一张中文句子表,我想找到所有包含字符串的记录。
例如:
irb(main):007:0> Hint.all
Hint Load (0.7ms) SELECT "hints".* FROM "hints"
[
[0] #<Hint:0x007fb99c9d1900> {
:id => 107,
:sentence => "你叫什么名字?",
:user => nil,
:learned => nil,
:created_at => Sat, 05 Jan 2013 21:04:06 UTC +00:00,
:updated_at => Sat, 05 Jan 2013 21:04:06 UTC +00:00
},
[1] #<Hint:0x007fb99f2acc30> {
:id => 108,
:sentence => "当时有约翰做他们的助手。",
:user => nil,
:learned => nil,
:created_at => Sat, 05 Jan 2013 21:04:23 UTC +00:00,
:updated_at => Sat, 05 Jan 2013 21:04:23 UTC +00:00
},
[2] #<Hint:0x007fb99f2ac618> {
:id => 109,
:sentence => "马可和家人可能过着舒适的生活,因为他们在城里有自己的房子,家里有仆人。",
:user => nil,
:learned => nil,
:created_at => Sat, 05 Jan 2013 21:19:43 UTC +00:00,
:updated_at => Sat, 05 Jan 2013 21:19:43 UTC +00:00
}
]
我想搜索“名字”,它会返回表中包含该字符串的记录sentence
列表。在这种情况下,它将在 [0] 中找到匹配项。
(如果需要全文搜索,能不能推荐一些能用中文和heroku,尽可能接近免费的东西?)