How to search a tree with sunspot & solr?

You basically want to search over a field that is composed of all of a thread's child nodes. You can do this with sunspot's block syntax. If the post is a root node, index all of the node's children (you'll have to implement all_children, which shouldn't be too hard) searchable do text :posts do all_children.

Map(&:post_body) unless parent end end Then search over this "posts" text field. Since you only indexed anything for root nodes, these are the only objects that will be returned in your result set.

You basically want to search over a field that is composed of all of a thread's child nodes. You can do this with sunspot's block syntax. If the post is a root node, index all of the node's children (you'll have to implement all_children, which shouldn't be too hard).

Searchable do text :posts do all_children. Map(&:post_body) unless parent end end Then search over this "posts" text field. Since you only indexed anything for root nodes, these are the only objects that will be returned in your result set.

Thank you, sir. That did the trick! – Adam Singer May 2 at 18:51 1 I would also suggest you use acts_as_nested_set instead of acts_as_tree.

It can handle the all_children call in a single query, whereas acts_as_tree could take many queries to achieve the same thing. – Dan Fox May 2 at 21:11.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions