Reputation: 129
I'm facing a bit of a conundrum.
I'm trying to build a search option as well as facets that will let users search by location of determined records.
The problem is that my database is structured as follows:
{Location (id, name)} has_many {User (id, name)} and user has_many {pins (id, name)}
My controller:
def index
@search = Pin.search do
fulltext params[:search]
order_by :created_at, :desc
end
@pins = @search.results
respond_to do |format|
format.html # index.html.erb
format.json { render json: @pins }
end
end
My Pins Model:
searchable do
text :title, :boost => 5
text :description
end
belongs_to :user
What can I do? Thankyou!
Upvotes: 0
Views: 97
Reputation: 2675
You can put whatever you want in your searchable
block like your associations and other things you need to be able to search.
searchable do
text :title, :boost => 5
text :description
text :location do
location.name
end
end
Upvotes: 2