在关联模型上思考 Sphinx Facets
无论如何,是否可以在关联模型的 int 类型列上定义构面?如果属于关联模型列,sphinx 是否会将定义为构面的所有字段转换为字符串?
我正在尝试将子表的一列定义为构面。之后 当我执行 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 - 使用 :through 连接模型
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>>
Is there anyway of defining facet on an associated model's column which is of type int?Does sphinx convert all fields defined as facets to strings if they are of an associated models columns?
I am trying to define a column of my child table as an facet.After
rebuilding when I do Model1.facets i get this error.
class Model1 < ActiveRecord::Base
....
has_many :communities, :through => :model2
...
define indexes
...
indexes model2.community_id, :as => :community_id, :facet => :true
...
end
end
model 1 - Current model
model 2 - join model using :through
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>>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用整数作为构面,那么它们应该被定义为属性:
indexes
方法用于字段 - 这是您希望人们能够搜索的文本数据。我猜使用您网站的人不会在搜索字段中输入社区 ID。如果情况并非如此,请发表评论,我将详细介绍如何将community_id
作为字段和属性。If you're using integers for facets, then they should be defined as attributes:
The
indexes
method is for fields - which are the textual data you want people to be able to search for. I'm guessing the people who use your site won't be entering in the community id into the search field. Leave a comment if that's not the case, and I'll expand on how you can have thecommunity_id
as both a field and an attribute.