2011-12-21 25 views
3

環境:Rails的Ruby的3.0.1的MySQL 1.8.7 5.5.16社區服務器... JDK 1.6太陽黑子Solr的不返回任何結果,但沒有錯誤

gem 'sunspot_rails' 
gem 'sunspot_solr' 

型號:

class Item < ActiveRecord::Base 

    searchable do 
    text :title,:description 
    end 

end 

控制器:

def search  
    p @items = Item.search { fulltext params[:search] }  
    @items.results.each do |item| 
     p item 
    end   
end 

我開始Solr的服務器,它啓動正常,我打開Solr管理在http://localhost:8982/solr/admin/

查詢.... q = 但沒有返回結果。

我運行rake太陽黑子:reindex ....在RAILS_ROOT \ solr \ data \ development \ index下創建新的索引文件。

我再次查詢Solr管理員與相同的查詢..still沒有結果...試圖找出什麼是錯的。

回答

5

「綱目瀏覽器」會告訴你,如果有你的索引中的任何數據

http://localhost:8982/solr/admin/schema.jsp 

一種

type:Item 
在Solr管理頁面

搜索應該告訴你的結果,如果您有任何您的數據庫中的項目

+1

我無法繼續http:// localhost:8982/solr/admin/schema.jsp導致HTTP錯誤500訪問/solr/admin/schema.jsp時出現問題。原因:未配置JSP支持。我試過'Topic.create!(內容:'測試提示雷達',user_id:1).index!'但是'r = Topic.search {fulltext'radar'};放r.hits'是空陣列......我該怎麼辦? – Matrix 2015-01-21 10:06:53