def self.search(params)
return [] unless params[:query].present?
tire.search(load: true) do
query { string(params[:query], fields: %w(title description topics
username discussions)) }
sort do
by "likes", "desc"
by "badges_count", "desc"
end
facet :tags do
terms :tags
end
facet :topics do
terms :topics
end
size params[:size] || 5
end.results
end
I'm attempting to perform a search on a particular model. Although the results are currently sorting based on the most likes, and I'd like to base it more on a percentage basis for each column in the sort block.
for example:
50% for "likes" based on strength of semantic match in another column(:header) 20% for "badges_count" based on "badges_count"
Any help would be great as I am a bit stuck on how to expand the block more and create a mini algorithm to sort based by weight.
Index your columns with boost options. ex:
Then remove sort from your search method. The query result will auto weight the likes and badges_count matches.