To edit pages or tickets please login with username/password: aaf/aaf

Ticket #52 (closed task: fixed)

Opened 2 years ago

Last modified 2 years ago

Return scores with SearchResults from find_by_contents

Reported by: pete@hitcity.com.au Assigned to: somebody
Priority: trivial Milestone:
Component: 1demo Version: 2.0
Keywords: return scores find_by_contents Cc:

Description

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 %>
  <tr><td>Name:</td><td><%=h business.name %></td></tr>
  <tr><td>Relevance:</td><td><%= @query_results.scores[business.id] %></td></tr>
<% end %>

Attachments

return_scores.patch (2.4 kB) - added by pete@hitcity.com.au on 10/11/06 01:07:22.
Patch to return scores with SearchResults? from find_by_contents

Change History

10/11/06 01:07:22 changed by pete@hitcity.com.au

  • attachment return_scores.patch added.

Patch to return scores with SearchResults? from find_by_contents

10/11/06 01:12:06 changed by pete@hitcity.com.au

  • type changed from defect to enhancement.

Changed type to enhancement

11/15/06 19:12:02 changed by jk@jkraemer.net

  • status changed from new to closed.
  • resolution set to fixed.

Implemented in trunk.

I did this in a slightly different way -

<%= business.ferret_score %>

looks way better, imho :-)

01/11/07 12:20:49 changed by volosok

  • type changed from enhancement to task.
  • version changed from 1.0 to 2.0.
  • component changed from component1 to component2.

c3eac8819df7 Hi vvv_5_1 vvv_5_1 vvv_5_2 vvv_5_2 vvv_5_3 vvv_5_3 vvv_5_4 vvv_5_4 vvv_5_5 vvv_5_5

To edit pages or tickets please login with username/password: aaf/aaf