I have a search method that combines the results from doing a fuzzy search using the fuzzily gem and doing a search in the tags used in acts_on_taggable gem.
if params[:search]
results = Post.find_by_fuzzy_title(params[:search])
tagged_results = Post.tagged_with("#{params[:search]}")
@posts = (Kaminari.paginate_array(results+tagged_results)).page(params[:page]).per(1)
else
The problem is that the returned query contains a concatenation of the two individual queries with duplicate results. What I would like to do is make sure a result is displayed only once even if it contains both a matching title and a matching tag to the search keywords.
Aucun commentaire:
Enregistrer un commentaire