I am scoping by multiple scalar fields and I am hoping to push the scoped results to the top of the search results without excluding results that do not meet the criteria for favorite authors.
Articles have and belong to many authors
This doesn't work but is what Im going for:
favorite_author_ids = @current_user.favorite_author_ids
@search = JournalArticle.solr_search do
fulltext params[:article_title]
any_of do
boost(2.0) {with(:author_ids), favorite_author_ids}
with(:author_ids), []
end
end
I suppose I could do two searches and concatenate the results, but Im wondering if there is a cleaner way.
It doesn't make sense to have the boost inside of an any_of block. You probably want to do something like this:
favorite_author_ids = @current_user.favorite_author_ids
@search = JournalArticle.solr_search do
fulltext params[:article_title] do
boost(2.0) {with(:author_ids, favorite_author_ids)}
end
end
You may need to increase the boost as well depending if you just want to increase the placement of favourite authors, or if you want them to always be at the top.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With