2011-01-19 69 views
0

是否有關於類型爲int的關聯模型列的定義方面?如果它們是關聯模型列,那麼sphinx是否將所有定義爲方面的字段轉換爲字符串?思考獅身人面像在關聯模型上的方面

我想將我的子表的一列定義爲facet.Alt 重建時,我做Model1.facets我得到這個錯誤。

class Model1 < ActiveRecord::Base 
    .... 

    has_many :communities, :through => :model2 

    ... 

    define indexes 

    ... 

    indexes model2.community_id, :as => :community_id, :facet => :true 

    ... 

    end 

end 

模型1 - 當前模型 模型2 - 加入模型中使用:通過

Model1.facets 

NoMethodError: undefined method `to_crc32' for 9:Fixnum 
     from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/ 
lib/thinking_sphinx/facet.rb:99:in `translate' 
     from (irb):3:in `detect' 
     from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/ 
lib/thinking_sphinx/facet.rb:98:in `each' 
     from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/ 
lib/thinking_sphinx/facet.rb:98:in `detect' 
     from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/ 
lib/thinking_sphinx/facet.rb:98:in `translate' 
     from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/ 
lib/thinking_sphinx/facet.rb:75:in `value' 
     from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/ 
lib/thinking_sphinx/facet_search.rb:114:in `add_from_results' 
     from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/ 
lib/thinking_sphinx/search.rb:219:in `each_with_groupby_and_count' 
     from (irb):3:in `each_with_index' 
     from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/ 
lib/thinking_sphinx/search.rb:218:in `each' 
     from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/ 
lib/thinking_sphinx/search.rb:218:in `each_with_index' 
     from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/ 
lib/thinking_sphinx/search.rb:218:in `each_with_groupby_and_count' 
     from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/ 
lib/thinking_sphinx/facet_search.rb:113:in `add_from_results' 
     from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/ 
lib/thinking_sphinx/facet_search.rb:49:in `populate' 
     from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/ 
lib/thinking_sphinx/facet_search.rb:47:in `each' 
     from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/ 
lib/thinking_sphinx/facet_search.rb:47:in `populate' 
     from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/ 
lib/thinking_sphinx/facet_search.rb:13:in `initialize' 
     from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/ 
lib/thinking_sphinx/search_methods.rb:422:in `new' 
     from D:/Current/TechAssistTest/vendor/plugins/thinking-sphinx/ 
lib/thinking_sphinx/search_methods.rb:422:in `facets' 
     from (irb):3>> 

回答

2

如果您正在使用方面整數,那麼它們應該被定義爲屬性的:

has model2.community_id, :as => :community_id, :facet => :true 

indexes方法適用於字段 - 這是您希望人們可以搜索的文本數據。我猜想,使用您的網站的人不會將社區ID輸入搜索字段。如果情況並非如此,請發表評論,我將詳細介紹如何將community_id作爲字段和屬性。

相關問題