I have a case where I do: has ["LOWER(`accounts`.`name`)"], :as => :sort_account_name, :type => :string
So, replace the "LOWER" function. "accounts" is the table and "name" is the column. You get the rest. I'm not sure how that would work, but it'll at least let you move to the next phase of tearing your hair out. On May 15, 12:39 pm, Rick Bradley <[email protected]> wrote: > Thuva, > Would users then be searching for values matching a given float (as a > string, e.g., "3.9")? I'm thinking that the precision of the decimal > portion of an average is likely to not match any string someone might > enter, except in degenerate cases (e.g, "0.0"), which makes me wonder > how this might be useful. > Best, > Rick > > > > On Fri, May 15, 2009 at 2:15 PM, Thuva Tharma <[email protected]> wrote: > > > I have a Business model that has many ratings (in a separate table). > > The average rating for a business is calculated as shown below: > > > class Business < ActiveRecord::Base > > has_many :ratings > > > def average_rating > > ratings.average(:value) # value is a field in Rating model > > end > > end > > > I would like to index the average rating for businesses via sphinx. I > > tried the following and got an error: > > > has "AVG(ratings.value)", :as => :rating, :type => :float > > > Can someone please let me know how to approach this problem? > > > Thank you in advance. > > > -- Thuva Tharma --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en -~----------~----~----~----~------~----~------~--~---
