使用 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=>[User(id: integer, gender: integer, name: string, family_name: string, email: string, crypt_pass:字符串,salt:字符串,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: datetime, updated_at: datetime, schedule_mon_0: boolean, schedule_mon_1: boolean, (...) schedule_available_holidays: boolean, destroy_email: string, destroy_at: datetime,birthday: date,mobility_km: integer, geo_search: string, geo_latitude: float, geo_longitude :浮动,geo_streetnumber:字符串,geo_route:字符串,geo_locality:字符串,geo_postal_code:字符串,geo_administrative_area_level_2: string, geo_administrative_area_level_1: string, geo_country: string, geo_type: string, email_verified_at: datetime)]}, @query="", @hash={}>
我试着做@facets.to_hash
,但它给了我这个错误:
不推荐使用老式的@variables(@count、@weight 等)
我被这个问题困住了,非常感谢您的帮助!