I'm using Thinking Sphinx to power the search on my Rails application.
I know the guide explicitly says that you can't index model methods, but I would like to. Specifically, I have a model whose instances can be tagged through a has_many_through
relationship via acts_as_taggable_on_steroids
. The important caveat: the model also nests via awesome_nested_set
, and I have tags inheriting through the nesting.
Here's how I'm searching for inherited tags:
def inherited_tags
retval = []
cat = self
while (cat = cat.parent)
retval += cat.tags
end
retval.uniq
end
I am able to search by explicit (not inherited) tags using:
define_index do
indexes title
indexes tags(:name)
end
This search seems to work just fine, but I'm having trouble combining them to allow users to search using inherited tags as well. Any advice is much appreciated!