在照片模型中,我有以下简单规则:
searchable do
string :note
end
我尝试用Solr搜索一些字符串(同时在两个表中)。这是终端中Solr 查询的输出(第一个是Articles,第二个是Photos):
SOLR 请求 (4.8ms) [ path=# parameters={data: fq=type%3A Article&q=searched_string&fl=%2A+score&qf=title+content&defType=dismax&start=0&rows=30 , method: post, params: {: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.4ms) [ path=# parameters={data: fq=type%3A Photo&q=asgasg&fl=%2A+score&defType=dismax&start=0&rows=30 , method: post, params: {: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模型中搜索...一切都应该指定和设置,但仍然不知道,问题出在哪里...