Im trying to use Searchkick to run a search and return based on multiple models.
My book model contains this
class Book < ActiveRecord::Base
sear
In your Book model you need to have a search_data
block for the indexing.
def search_data
attributes.merge(
author_name: author(&:name)
publisher_name: publisher(&:name)
subjects_name: subjects.map(&:name)
)
end
this will add the associations to your index.
You use the .map
method for the has_many
associations.