Sorry, have held off on replying to this because it's a little complex (and I'm working ;)
Grouping only works for attributes, and attributes aren't strings. Yes, you can define attributes using strings, but they get translated into ordinal integers (integers indicating alphabetical order) - useful for sorting, but not filtering or grouping. Also, I noticed in your index definition you've got a field *and* an attribute named :city - I highly recommend changing one of them, otherwise the SQL query that gets generated will have two columns named city, and Sphinx may get confused when processing the index data. To get a breakdown via string values, the only way I can think of doing this without changing your database structure (to push cities into their own tables, use the foreign key as the grouping value), is to use facets instead. http://freelancing-god.github.com/ts/en/facets.html This is still not ideal, and any string facets are slow, but probably the best way forward if this is an essential feature. -- Pat On 01/06/2010, at 4:36 PM, badnaam wrote: > Folks any ideas? Why am I getting a fixnum for city, instead of a > string? > > > On May 31, 9:34 pm, badnaam <[email protected]> wrote: >> Specifically ..how can I get a listing like.. >> >> category_1 >> record1 >> record2 >> record3 >> category_2 >> record1 >> >> .. >> There does not seem to be a way to get the categories..like >> results.keys..the way I have done with normal rails group_by queries. >> >> On May 31, 9:23 pm, badnaam <[email protected]> wrote: >> >>> I am not getting any luck with the docs, here is my search.. >> >>> m1 = ThinkingSphinx.search(:geo => ll, :with => {"@geodist" => 0.00.. >>> (40 * 1609.344)}, :latitude_attr => :lat, :longitude_attr >>> => :lng, :sort_by =>:created_at, :classes => [Merchant], :group_by => >>> "city", :group_function => :attr, :group_clause => "@count desc") >> >>> I would assume when I do the following I would see a list of >>> cities..but I see a bunch of integers. Is there an example of how to >>> loop through the results? >> >>> m1.each_with_groupby do |rec, group| >>> puts group >>> end >> >> > > -- > 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. > -- 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.
