【发布时间】:2016-03-14 00:12:18
【问题描述】:
我正在尝试使用 Sunspot_Solr 将搜索功能添加到一个简单的应用程序,但是连接一直被拒绝。
这是我从错误页面得到的结果:
Showing /Users/danieluribe/code/other/shouter2/app/views/searches/_search.html.erb where line #2 raised:
Connection refused - {:data=>"fq=type%3AShout&start=0&rows=30&q=*%3A*", :method=>:post, :params=>{:wt=>:ruby}, :query=>"wt=ruby", :headers=>{"Content-Type"=>"application/x-www-form-urlencoded; charset=UTF-8"}, :path=>"select", :uri=>#<URI::HTTP http://localhost:8983/solr/development/select?wt=ruby>, :open_timeout=>nil, :read_timeout=>nil, :retry_503=>nil, :retry_after_limit=>nil}
Extracted source (around line #11):
def shouts
# Shout.text_shouts.where(content_id: text_shouts)
Shout.search do
fulltext @term
end.results
end
Trace of template inclusion: app/views/searches/show.html.erb
我已经添加了 Sunspot_Solr 和 Sunspot_Rails gem。我继续运行生成器,它在 config 文件夹中创建了 Sunspot.yml 文件。
错误指向我的名为 Search.rb 的模型文件。这是上面部分删除了 cmets 的完整文件参考。
class Search
include ActiveModel::Conversion
attr_reader :term
def initialize options = ()
@term = options.fetch(:term, "")
end
def shouts
Shout.search do <--- Error points here
fulltext @term
end.results
end
end
我继续使用 rake 任务启动 Sunspot_Solr。然后我进入控制台重新索引我的数据库。我还关注了此处回答的一些问题并更改了端口,但无济于事。
有人知道问题可能是什么吗?
【问题讨论】:
-
你能把
Sunspot.config.solr.url = 'http://localhost:8983/solr'加到config/production.rb吗
标签: ruby-on-rails ruby solr sunspot