Class: Ferret::Search::TopDocs
- Inherits:
-
Object
- Object
- Ferret::Search::TopDocs
- Defined in:
- ext/r_search.c
Overview
Summary
A TopDocs object holds a result set for a search. The number of documents that matched the query his held in TopDocs#total_hits. The actual results are in the Array TopDocs#hits. The number of hits returned is limited by the :limit
option so the size of the hits
array will not always be equal to the value of total_hits
. Finally TopDocs#max_score holds the maximum score of any match (not necessarily the maximum score contained in the hits
array) so it can be used to normalize scores. For example, to print doc ids with scores out of 100.0 you could do this;
top_docs.hits.each do |hit|
puts "#{hit.doc} scored #{hit.score * 100.0 / top_docs.max_score}"
end