'name' is actually a field, not an attribute - and Sphinx doesn't allow for grouping by fields. If you're using a 2.x release of Sphinx, you could try something like the following:
define_index do
indexes name
has name, :as => :group_name
end
Company.search query, :group_by => :group_name, :group_function => :attr
Fields and attributes can't share names, hence why I've given the attribute the name 'group_name'.
Cheers
--
Pat
On 10/09/2012, at 6:55 AM, Anton Grigoriev wrote:
> Hello,
>
> While trying to group search results by attribute 'name', which is being indexed, get error "group-by attribute 'name' not found".
>
> I've defined index for my Company model like this:
>
> define_index do
> indexes :name
> end
>
> Then I'm trying to make a search with grouping result by 'name':
>
> @companies = Company.search query, :group_by => 'name', group_function => :attr
>
> and get the error. Could you tell me, please, what I'm missing.
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/733p9JEatbcJ.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.