class Orchestrate::Search::StatsResult

Stats Aggregate result object

Attributes

max[R]

@return [Float] Highest numerical value of the statistics result

mean[R]

@return [Float] Average of included numerical values

min[R]

@return [Float] Lowest numerical value of the statistics result

statistics[R]

@return [Hash] The statistics results

std_dev[R]

@return [Float]

sum[R]

@return [Float] Total of included numerical values

sum_of_squares[R]

@return [Float]

variance[R]

@return [Float]

Public Class Methods

new(collection, listing) click to toggle source

Initialize a new StatsResult object @param collection [Orchestrate::Collection] The collection searched. @param listing [#to_json] The aggregate result returned from the search.

# File lib/orchestrate/search/results.rb, line 153
def initialize(collection, listing)
  super(collection, listing)
  if listing['statistics']
    @statistics = listing['statistics']
    @min = @statistics['min']
    @max = @statistics['max']
    @mean = @statistics['mean']
    @sum = @statistics['sum']
    @sum_of_squares = @statistics['sum_of_squares']
    @variance = @statistics['variance']
    @std_dev = @statistics['std_dev']
  end
end

Public Instance Methods

inspect()
Alias for: to_s
to_s() click to toggle source

@return Pretty-Printed string representation of the StatsResult object

# File lib/orchestrate/search/results.rb, line 168
def to_s
  stats = "statistics={\n  min=#{min},\n  max=#{max},\n  mean=#{mean},\n  sum=#{sum},\n  sum_of_squares=#{sum_of_squares},\n  variance=#{variance},\n  std_dev=#{std_dev}\n}"
  "#<Orchestrate::Search::StatsResult collection=#{collection.name} field_name=#{field_name} count=#{count} #{stats}>"
end
Also aliased as: inspect