Searching has_many with UltraSphinx

I’m switching from ferret to ultrasphinx… in ferret I used to search on tags for a model by just including the tag_string method in the list of fields and implementing this method:

def tag_string tags.map(&:name).join(“,”) end

Does anyone know how to get at this kind of info using sphinx? My huntch is that it needs to use the ;include syntax somehow.

Thanks

I'm also switching from Ferret to Ultrasphinx. I was using acts_as_taggable to search tags for Product models. Now I'm getting a "FATAL: no sources found in config file" error when I try to "rake ultrasphinx:index". I am suspecting this is due to the fact that I tried writing "is_indexed :fields => [:tag_list]" in my Product model. Any ideas?

To index your model with tagging, check the post from 'Allan Riley' on March 29 2008 here: http://rubyforge.org/forum/forum.php?thread_id=18082&forum_id=14244

Hope that helps!

<a href="http://www.kiranatama.com">Kiranatama - a Ruby on Rails outsourcing company</a>

Check out the :concatenate parameter of :is_indexed (http:// blog.evanweaver.com/files/doc/fauna/ultrasphinx/classes/ActiveRecord/ Base.html). We wanted to treat the tags as a single text field and to do that you need to write some custom sql but here's what we're using:

class Product   acts_as_taggable   is_indexed :fields => ['name', 'description'],     :concatenate => [{ :class_name => 'Tag', :field => 'name', :association_sql => "LEFT JOIN taggings ON ((taggable_id = product.id) AND (taggable_type = 'Product')) LEFT JOIN tags ON (tags.id = taggings.tag_id)", :as => 'tags' }] end

which is also covered in the link KiranaTama posted....