Class Ferret::Search::TopDocs
In: ext/r_search.c
Parent: Object

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

Methods

to_json   to_s  

Public Instance methods

Returns a json representation of the top_doc.

Returns a string representation of the top_doc in readable format.

[Validate]