ruby on Rails 插件acts_as_ferret 是否有很多错误?
我正在使用acts_as_ferret 对我的数据库进行非常简单的搜索。 我把它放在我的“场地”模型中:
acts_as_ferret :fields => [:name, :city]
这是在我的控制器搜索操作中:
@t = Venue.find_by_contents(params[:search]+'~')
然后我只渲染结果。
render :text => @t.to_json, :success => true, :status => :ok
如果我运行快速测试:
http://localhost:3000/venue/list?search=The
我在日志中看到正在索引上执行正确的查询“The~”。 但是,我没有得到任何结果。 我肯定有一些名称字段中带有“The”一词的“场地”。
由于这是一个非常简单的搜索,并且使用了相当多的acts_as_ferret,因此我尝试重建索引以查看它是否已损坏......没有骰子
有什么想法吗?
谢谢!
I am doing a very simple search on my DB using acts_as_ferret. I put this in my "Venue" model:
acts_as_ferret :fields => [:name, :city]
And this is in my controller search action:
@t = Venue.find_by_contents(params[:search]+'~')
and then I just render the results.
render :text => @t.to_json, :success => true, :status => :ok
If I run a quick test:
http://localhost:3000/venue/list?search=The
I see in my log that the proper query "The~" is being executed on the index. However, I get no results. I definitely have a few "Venues" with the word "The" in the name field.
Since this is a very simple search and acts_as_ferret is used quite a bit, I tried rebuilding the index to see if it was corrupted....no dice
Any ideas?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,Ferret 因破坏索引而闻名。
我建议切换到另一个搜索插件,例如 Thinking Sphinx。 您可以观看有关它的 Railscast 以了解更多信息。
Yes, Ferret has been very well known for corrupting indexes.
I recommend switching over to another searching plugin like Thinking Sphinx. You can watch the Railscast about it in order to learn more.
我认为问题可能是“the”被定义为一个停用词——一个非常常见的词,没有被索引,因为它只会返回每个文档。 您可以配置停用词列表。
如果您在使用 Ferret 时遇到问题,我会考虑使用 Solr。
I think the problem might be that "the" is defined as a stopword- an extremely common word that is not indexed because it would just return every document. You can configure your stopword list.
I would consider using Solr if you are having problems with Ferret.