【发布时间】:2013-11-09 09:31:26
【问题描述】:
使用 V3,我无法显示构面:s:
我使用 Rails 4.0.1、thinking-sphinx (3.0.6),最近在 MacOS 10.9 上使用 'brew install sphinx --mysql' 安装了 sphinx
我这样定义我的索引:
ThinkingSphinx::Index.define :user, with: :active_record, delta: ThinkingSphinx::Deltas::DelayedDelta do
#attributes
has 'users.banned_at IS NULL and users.email_verified_at IS NOT NULL', as: :searchable, type: :boolean, facet: true
has 'RADIANS(geo_latitude)', as: :latitude, type: :float
has 'RADIANS(geo_longitude)', as: :longitude, type: :float
has gender, facet: true
end
在我的控制器中:
@users = User.search with: {geodist: 0.0..100_000.0},
geo: [City.first.latitude, City.first.longitude]
@facets = @users.facets
然后在我看来(HAML 语法)与 V2 相同的代码,这使我什么也没有:
-@facets.each do |facet, facet_options|
- %h5= facet
- %ul
-facet_options.each do |option, count|
-%li= link_to "#{option} (#{count})" (...)
@facets.inspect 给我这个:
{:geodist=>0.0..100000000.0}, :geo=>[46.15, 4.91667], :classes=>[用户(id:整数,性别:整数,名称:字符串, family_name:字符串,电子邮件:字符串,crypt_pass:字符串,盐:字符串, auth_token:字符串,verif_token:字符串,password_reset_token:字符串, password_reset_sent_at:日期时间,city_id:整数,oauth_provider: 字符串,oauth_uid:整数,oauth_token:字符串,oauth_expires_at: 日期时间,last_login_at:日期时间,banned_at:布尔值,created_at: 日期时间,updated_at:日期时间,schedule_mon_0:布尔值, schedule_mon_1:布尔值,(...) schedule_available_holidays:布尔值, destroy_email:字符串,destroy_at:日期时间,生日:日期, 移动公里:整数,地理搜索:字符串,地理纬度:浮动, geo_longitude:浮动,geo_streetnumber:字符串,geo_route:字符串, geo_locality:字符串,geo_postal_code:字符串, geo_administrative_area_level_2:字符串, geo_administrative_area_level_1:字符串,geo_country:字符串, geo_type: string, email_verified_at: datetime)]}, @query="", @hash={}>
我尝试创建@facets.to_hash,但它给了我这个错误:
不推荐使用老式的@variables(@count、@weight 等)
我遇到了这个问题,非常感谢您的帮助!
【问题讨论】:
标签: ruby-on-rails-4 sphinx thinking-sphinx