Hi all,

I have a DB with records which look something like this:

Node
  uid: <.....>
  source_uid:  <....>
  ...

A root node has a null source_uid,
child nodes will have the source uid set with the uid of a root node.

Anyway - in rails I have my fancy has_many relationship:

class Node
 
has_many :descendants, :class_name=>"Node", :foreign_key=>'source_uid', 
:primary_key=>'uid'
end

In Sphinx the attribute I want to add is 'descendant_count'.

To be able so sort a query result based on how many descendants the
node has.

Is there any way to do this?
I have tried:

has descendants.count
has descendants(:count)
has descendants
....

Nothing seems to generate valid SQL - so ts:rebuild ends up throwing
out exceptions on me.

What I want to do is basically do a sub-query, get the # of
descendants, and save that count as an integer in the sphinx index for
each record.

Any ideas?

Thanks!
Cary

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