You'll have to do *one* of the two following things:
- Add that column as a sortable field (if you want the contents  
indexed for searching)
   indexes category.category_translations, :as => :category, :sortable  
=> true
- Or, add it as an attribute, which is implicitly sortable, but not  
indexed for searching
   has category.category_translations, :as => :category

And then stop Sphinx, re-index and restart Sphinx (rake  
thinking_sphinx:rebuild if you're running a new version of TS) and  
then you can search as follows:
   Track.search 'beat', :order => :category # or 'category ASC'

The problem with your current approach: Sphinx doesn't use SQL for  
searches. :joins and table names in :order mean nothing to Sphinx, and  
so it gets confused and returns no results.

Cheers

-- 
Pat

On 31/05/2009, at 11:04 AM, j0llyr0g3r wrote:

>
> Hey guys,
>
> i have a model "track" with the following index structure:
>
>  define_index do
>    indexes tags, :sortable => true
>    indexes short_description, :sortable => true
>    indexes full_description, :sortable => true
>    indexes artist, :sortable => true
>    indexes title, :sortable => true
>  end
>
> This works fine so far....
>
> Now, my model "track" has a belongs_to-association to the model
> "category", which in turn has a "has_many"-association to the model
> "category_translations" (globalize2)
>
> So i thought i could do the following query and get back the results
> sorted via category-name:
>
> Track.search 'beat', :order => 'category_translations.name
> ASC', :joins => {:category => :category_translations}
>
> but this gives me an empty resultset.
>
> In my log-files i can see the error:
>
> Sphinx: beat
> Sphinx Result: []
> Sphinx Error: index track_core: sort-by attribute
> 'category_translations' not found
>
> What do i have to do in order to be able to sort after the category-
> name?
> Do i have to index it separately?
> >


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to