I have a Piece model with a boolean attribute of published.
I want the search results to only contain Pieces that are plublished: true.
My index action for the PiecesController is:
def index
@list = params[:list]
@sort = params[:sort]
if params[:q]
@pieces = Piece.search(params[:q]).records
else
@pieces = Piece.all_in_category(@list, @sort)
end
end
From searching around it seems that I should overwrite the search method in the Piece controller but I am not sure the correct way of doing this to maintain the current search methods functionality.
What is the best way to filter the elasticsearch results using the elasticsearch-rails gem?