Grouping search results with thinking_sphinx plugin for rails
- by Shagymoe
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."