#136 ✓resolved
Jens

Return scores with SearchResults from find_by_contents

Reported by Jens | February 13th, 2010 @ 12:44 AM

I understand that I could use find_id_by_contents directly to obtain resulting ids with respective scores however I would then have to repeat some of the processing in find_by_contents to load the actual records from the database. I would prefer instead if the find_by_contents method would store the scores it receives from find_id_by_contents and return them with the [[SearchResults]].

I have attached a patch that does this. Basic example usage would look like this:

In controller:

@query_results = Business.find_by_contents params[:query]

In view:

<% for business in @query_results %>
  
Name: <%=h business.name %>

  
Relevance: <%= @query_results.scores[business.id] %>

<% end %>

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Shared Ticket Bins

People watching this ticket

Pages