This question has been asked several times before and answered but none of the suggestions seem to work in my case.
I have a User model and Micropost model
A user has many microposts, a micropost has one user.
I am trying to search across the user model and micropost model at the same time using Sunspot.
All I need is the correct syntax for indexing the models.
I tried this:
class User < ActiveRecord::Base
searchable do
text (:full_name)
text (:last_name)
text (:first_name)
text (:email)
text (:job_title)
text (:city)
text (:country)
text (:address)
text (:tag_list)
text (:content ) { micropost.content }
end
end
Based on
sunspot solr how to search multiple models correctly? All examples online fail
but this doesn't work. All I need is to search the content attribute of the micropost above. So if a person searches for a user, they get a user, if they search for a specific phrase that occurs in a micropost.content, they get the micropost(s) with that phrase.
The documentation doesn't help on this as far as I can see.