Try this ( Rails 2.x syntax):
Note.all(
:select => "notes.*, COUNT(notes.id) AS note_count",
:joins => :note_categories,
:conditions => ["notes.description LIKE ?", "test string%"],
:group => :id,
:order => :note_count
)
Edit 1
My answer does not use the scopes created by seach_logic
and it will work.
If you are using SearchLogic, your query can be written as:
Note.description_like("test string").all(
:select => "notes.*, COUNT(notes.id) AS note_count",
:joins => :note_categories,
:group => :id,
:order => :note_count
)