2016-03-14 114 views
2

我試圖添加搜索功能,使用Sunspot_Solr一個簡單的應用程序,但是,連接不斷被拒絕。太陽黑子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寶石。我繼續運行在config文件夾中創建Sunspot.yml文件的generator。

錯誤指向我的標題爲Search.rb的模型文件。以下是部分上面的完整文件參考,刪除了註釋。

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 

我繼續用耙任務啓動Sunspot_Solr。然後我進入控制檯重新編制我的數據庫。我也跟着一些在這裏回答的問題,並改變了港口,無濟於事。

會有人知道這個問題可能是什麼?

+0

可以添加'Sunspot.config.solr.url =的「http://本地主機:8983/solr''到'config/production.rb' –

回答

1

試試這個:

添加Sunspot.config.solr.url = 'http://localhost:8983/solr'config/production.rb

您可以重新索引

rake sunspot:solr:reindex RAILS_ENV=production 

如果還是不行...再

rm solr/pids/production/sunspot-solr-production.pid 

start solr 

rake sunspot:solr:start RAILS_ENV=production 

重新索引

rake sunspot:solr:reindex RAILS_ENV=production 
+0

我的'Sunspot.config.solr.url ='http:// localhost:8983/solr''已經在我的配置文件中。我沒有幸運地跑過其他步驟。我得到以下內容:'RSolr :: Error :: ConnectionRefused:連接被拒絕',後面跟着一個長散列。 –

+0

您是否添加了任何您想索引的可搜索塊?你可以看到教程http://railscasts.com/episodes/278-search-with-sunspot –

+0

我正在按照Upcase的教程,他們最初做了自己的搜索功能工作。然後他們轉而使用太陽黑子寶石。這是一個推特克隆,所以我正在尋找喊聲(推文)。 –

0

馬爺被你的Solr服務器未啓動使用此命令

耙太陽黑子:Solr的:開始