views:

31

answers:

1

I can use the following to group results, but it only returns one result per group.

    @results = Model.search params[:search_query], 
                            :group_by => 'created_at',
                            :group_function => :day,
                            :page => params[:page],
                            :per_page => 50         

So, if I display the results by day, I only get one result per day.

<% @results.each_with_groupby do |result, group|  %>
  <div class="group"><%= group %></div>    
  <ul class="result">
    <li><%= result.name %></li>
  </ul>
<% end %>

Do I have to parse the @results array and group them by date manually or am I missing something? Here is the line from the sphinx docs: http://sphinxsearch.com/docs/current.html#clustering

"The final search result set then contains one best match per group."

A: 

Here's similar documentation for thinking_sphinx:

http://freelancing-god.github.com/ts/en/searching.html#grouping

Unfortunately, I'm not sure I understand your question enough to give you a better answer at the moment. Care to clarify?

jerhinesmith