Aggregate query functions average, count, maximum, minimum, and sum should be supported on document fields to aid in reporting run against document field values.
Desired usage for declaring and gathering aggregate support would be:
class MyClass
do_document_fields
document_field :num_friends, :aggregate=>[:average, :count, :sum]
document_field :num_hours, :aggregate=>true # or :aggregate=>:all
end
MyClass.average(:num_friends) => 78 #average number of friends
MyClass.maximum(:num_friends) => Error #method :maximum not declared on num_friends
MyClass.minimum(:num_hours) => 2 #minimum number of hours
Declaration can optionally (additionally?) be supported using a "document_aggregate" method or a variation of the "document_index" method.
Aggregates will be stored using cache-counting within the search index table for the class. This keeps only one support table in the database for both index/finder support and aggregate support.