Scoring by field


#1

Hello,

I’ve added a feature to Ferret that breaks down the score
of each matched document by the contribution from each of
the document’s fields.

IndexSearcher now has a search_each_with_field_scores method,
and TopDocs has an each_with_field_scores method. Both yield
a third parameter, being a new score_by_field attribute of
ScoreDoc. score_by_field is a hash with field_name keys and
score values.

I find this useful when I have indexed a document by using a
separate field for each section of the document. The score
breakdown can be used to provide a user with not only a link
to each document in the search results, but to also a link to
the most relevant section of those documents.

Would this be something worthwhile to integrate into the Ferret
distribution? None of the high-level APIs are broken, though
scorers now return an array pair [score, score_by_field], rather
than just the score.