Maybe using group_by will work except I am trying to figure out how to use the
:group_function :attr can this be grouped on a field instead of an attribute? the field I need to group on is holder_type indexes :image_holder_type, :as => :holder_type On Aug 2, 11:26 pm, gerberdata <[email protected]> wrote: > Pat, > > here is the gist of what we are doing > > if image_holder == "Car" > tagger_key = [@image_holder.to_search_key, > @image_holder.dealerships.collect{|dealership| > dealership.to_search_key}].flatten.join(" | ") > end > conditions = "@tagger_keys (#{tagger_key})" > query_text = @s_query.blank? ? conditions : @s_query + "* & " + > conditions > > then we run the search > > images = Image.search query_text || "", :include=>[:tags], :per_page > => @image_holder.blank? ? $LIST_PER_PAGE : > @per_page, :page=>@current_page, :order=>"tagger_keys asc, created_at > DESC", :match_mode => :boolean > > this produces a result where we get the records in the correct order > according to our tagger_keys, but the created_at is not showing > in the proper descending order. So the created_at DESC does not seem > to be run properly we need to show the most recent images within each > tagger_keys > > in our images model we have the tagger_keys sortable > indexes tags.tagger_key, :as => :tagger_keys, :sortable => true > > So basically the date order is what is not working in this current > form. > > Thanks for the help > > Dave > > On Aug 2, 8:22 pm, gerberdata <[email protected]> wrote: > > > > > > > > > we get all the image keys for a car first, then we get all the keys > > for a car.dealers and then we join all > > those keys together and pass it into search with the or expression. > > We need to prioritize this result firstly by the car and then the most > > recent car image, and then by the car dealer and the most recent > > image of the car dealer. Right now the result returns only in > > the date order. > > > Is this possible? > > > On Aug 2, 7:38 pm, Pat Allan <[email protected]> wrote: > > > > Not sure if I quite understand this - do you want to prioritise a > > > specific image_holder_id, and then sort firstly within that id by date, > > > and then all other results by date? > > > > -- > > > Pat > > > > On 03/08/2011, at 12:04 PM, gerberdata wrote: > > > > > Looking to get some help and ideas for this issue I have here. Maybe > > > > one of the excellent minds on > > > > this board can help > > > > > @images = Image.search > > > > key1,key2,key3 , :per_page=>1, :page=>pos, :order=>"created_at > > > > DESC", :match_mode => :boolean > > > > > I need to be able to sort as follows > > > > > 1. keep the created_at DESC as the first sort > > > > 2. have an additional sort which sorts on the image_holder_id > > > > > here is the indexing for image_holder_id > > > > has :image_holder_id, :as => :holder_id > > > > > so can picture it this way I have a url for one particular cars > > > > profile and > > > > I want to show the images of the car first and then the related > > > > things to car > > > > > imageofcar1 created today image_holder:current_car > > > > imageofcar2 created today image_holder:current_car > > > > imageofcardealer created today image_holder:car_dealer > > > > imageofcardealer created today image_holder:car_dealer > > > > imageofcardealer created yesterday image_holder:car_dealer > > > > imageofcardealer created yesterday image_holder:car_dealer > > > > > But my current result is this > > > > imageofcardealer created today image_holder:car_dealer > > > > imageofcar1 created today image_holder:current_car > > > > imageofcardealer created today image_holder:car_dealer > > > > imageofcar2 created today image_holder:current_car > > > > imageofcardealer created yesterday image_holder:car_dealer > > > > imageofcardealer created yesterday image_holder:car_dealer > > > > > this is wrong because I want to show the imagesofcars first then the > > > > images of cardealers > > > > > -- > > > > 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.
