Hi Pat Thanks for getting back to me mate. Greatly appreciated!
Yeah, that sounds like a good idea, I hadn't thought of it like that - it just takes thinking about things a little differently. Thanks for the pointer. Is there any more information on the difference between using group_by in the search query and using it in the index? If you group in the index by one field and then use group by in the search query on another field, what would be happening behind the scenes there? Also, is it possible to set the group clause when grouping at the index level to set the order by which the records are grouped? Thanks again Shaun On Jan 23, 9:14 pm, Pat Allan <[email protected]> wrote: > Hi Shaun > > There was support for grouping on a pair of attributes back in Sphinx 0.9.8, > but that was really just a hack for 64bit int support, which is now in > 0.9.9.http://www.sphinxsearch.com/forum/view.html?id=890http://www.sphinxsearch.com/forum/view.html?id=4325 > > If you want results grouped by format and title together, why not set a > single attribute that CRC's both of them? > has "CRC32(CONCAT(format, title))", :as => :group_num, :type => :integer > > -- > Pat > > On 22/01/2010, at 7:35 PM, Shaun wrote: > > > > > Hi there > > > Is there a way I can group my results by multiple attributes? I have > > many records that contain the same data in a few fields and need to > > collapse them into one record. Am I right in thinking the :group_by > > option in the search method only allows one attribute to be specified? > > I have tried :group_by => 'field_one, field_two' but I then get zero > > results from the search. I am also specifying the group_function as > > attr and a group_clause as results within the group need to be > > ordered: > > > Product Model: > > > define_index do > > indexes title > > > has "CRC32(format)", :as => :num_format, :type => :integer > > has "CRC32(title)", :as => :num_title, :type => :integer > > has "COUNT(DISTINCT suppliers.id)", :as => :supplier_count, :type > > => :integer > > end > > > @products = Product.search( > > :conditions => {:title => params[:q]}, > > :page => params[:page] || 1, > > :index => 'product_core', #I have another index in the > > same model > > :group_by => 'num_format', > > #would like to say :group_by => 'num_title, num_format', > > :group_function => :attr, > > :group_clause => "supplier_count desc" > > ) > > > Is there something else I should be doing? > > > Any suggestions welcome! > > > Many thanks > > > Shaun > > > -- > > 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 > > athttp://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.
