Hi,
I have a very common problem which should be normally already solved by someone, but even after days of researching I couldnt find any solutions.
Here is the problem I'm trying to solve:
I have two models
Destination
has_many :interests
Interest
belongs_to :destination
The interest model has a name and a score. So I could have the following setup:
A destination "miami" which has an interest "beach" of score "9"
A destination "New York" which has an interest "beach" of score "6"
In the destination model I setup the sunspot searchable block something like this:
searchable :auto_index => true, :auto_remove => true do
integer :interest_ids, :multiple => true do
index_interest_ids
end
end
def index_interest_ids
interests.map do |interest|
if interest.score > 5
end
end
end
So far so good. When I now do a sunspot search for beach it brings me back all the destination which have an interest of beach scored higher than 5. But now I would like to rank the results based on the score. So when I search for beach, Miami should ranked higher than New York.
Anybody an idea how this could work?