Given this (fictional) setup.
class Folder < ActiveRecord::Base
# Fields: id, name
has_many :files
define_index do
indexes name
indexes
files.name, :as => :file_names
end
end
class File < ActiveRecord::Base
# Fields: id, folder_id, name
belongs_to :folder
end
irb> folder = Folder.create!(:name => 'no-match')
irb> folder.files.create!(:name => 'matching-text')
Given that I've indexed, I can issue these queries to return the
matching folder object:
irb> ThinkingSphinx.search 'matching-text'
irb> Folder.search 'matching-text'
How would I go about displaying an excerpt in this case? The
#excerpts method just returns the folder object with the name field
html escaped. I'd expect (although I'm new to thinking_sphinx/sphinx
so this might not be possible) to be able to use something like
result.excerpts.file_names (i.e. the alias in Folder.define_index) to
get something that I could display in my search results. Should I be
doing something else or is this not possible at the moment?
Cheers, Chris