在 Rails 中查找带有 ferret 的 á、à 等字符
我有一个 Rails 项目,有 ferret 正在处理它。我还有一些带有法国和西班牙名字的桌子。其中包含以下字符:á、à。 ü 等 当我进行搜索时,我只使用常见字符,这使得我无法使用“berche”等关键字在数据库中找到“bèrché”之类的内容。 我尝试用“?”之类的通配符替换人声。或“*”,但它似乎不起作用。
这是代码:
# controller
default_options = {:limit => :all}
@results_ferret = Model.find_with_ferret(params["search_words"], default_options)
# model
class Model < ActiveRecord::Base
require 'acts_as_ferret'
acts_as_ferret({:fields => [:region, :origin, :something, :name, :content], :remote => true})
end
有什么想法如何继续吗?
I have a rails project with ferret working on it. Also I have some tables with french and spanish names in there. That contains characters like: á, à. ü, etc.
When I made a search I only use common characters and that makes me impossible to find in the database something like "bèrché" using a keyword like "berche".
I tried to replace the vocals with a wildcard like "?" or "*", but it doesn't seems to work.
Here is the code:
# controller
default_options = {:limit => :all}
@results_ferret = Model.find_with_ferret(params["search_words"], default_options)
# model
class Model < ActiveRecord::Base
require 'acts_as_ferret'
acts_as_ferret({:fields => [:region, :origin, :something, :name, :content], :remote => true})
end
Any ideas how to proceed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Ferret 在构建索引时需要了解区域设置。它通过查看环境变量“LANG”来实现这一点。我们有一个名为 ferret:rebuild 的 rake 任务,所以对我们来说它看起来像这样:
如果这不起作用,请检查您的数据库排序规则。
供您参考
我们的 rake 任务如下所示:
Ferret needs to know about the locale when building the index. It does so by looking at environment variable 'LANG'. We have a rake task called ferret:rebuild so for us it looks like this:
If this does not work, check out your database collation.
For your reference
Our rake task looks like this: