【发布时间】:2012-03-07 17:24:19
【问题描述】:
在 Photo 模型中,我有以下简单规则:
searchable do
string :note
end
我尝试使用 Solr 搜索一些字符串(同时在两个表中)。这是终端中 Solr query 的输出(第一个用于Articles,第二个用于Photos):
SOLR 请求(4.8 毫秒)[路径=# 参数={数据:fq=type%3A Article&q=searched_string&fl=%2A+score&qf=title+content&defType=dismax&start=0&rows=30,方法:post,参数:{:wt=>:ruby},查询:wt=ruby,标题: {"Content-Type"=>"application/x-www-form-urlencoded; charset=UTF-8"}, 路径:选择,uri:http://localhost:8982/solr/select?wt=ruby, open_timeout: , read_timeout: } ]
还有这个
SOLR 请求(4.4 毫秒)[路径=# 参数={数据:fq=type%3A Photo&q=asgasg&fl=%2A+score&defType=dismax&start=0&rows=30,方法:post,参数:{:wt=>:ruby},查询:wt=ruby,标题: {"Content-Type"=>"application/x-www-form-urlencoded; charset=UTF-8"}, 路径:选择,uri:http://localhost:8982/solr/select?wt=ruby, open_timeout: , read_timeout: } ]
控制器:
@articles = Article.search do
fulltext params[:search]
end
@photos = Photo.search do
fulltext params[:search]
end
## => searching ##
puts @articles.results #work fine
puts @photos.results #always 0
我完全不知道,为什么 SOLR 不在 Photo 模型中搜索...一切都应该指定和设置,但仍然不知道问题出在哪里。 ..
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 full-text-search sunspot-rails sunspot-solr