Class: Orchestrate::Search::StatsResult

Inherits:
AggregateResult show all
Defined in:
lib/orchestrate/search/results.rb

Overview

Stats Aggregate result object

Instance Attribute Summary collapse

Attributes inherited from AggregateResult

#collection, #count, #field_name, #kind

Instance Method Summary collapse

Constructor Details

#initialize(collection, listing) ⇒ StatsResult

Initialize a new StatsResult object

Parameters:

  • collection (Orchestrate::Collection)

    The collection searched.

  • listing (#to_json)

    The aggregate result returned from the search.



153
154
155
156
157
158
159
160
161
162
163
164
165
# 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

Instance Attribute Details

#maxFloat (readonly)

Returns Highest numerical value of the statistics result.

Returns:

  • (Float)

    Highest numerical value of the statistics result



133
134
135
# File 'lib/orchestrate/search/results.rb', line 133

def max
  @max
end

#meanFloat (readonly)

Returns Average of included numerical values.

Returns:

  • (Float)

    Average of included numerical values



136
137
138
# File 'lib/orchestrate/search/results.rb', line 136

def mean
  @mean
end

#minFloat (readonly)

Returns Lowest numerical value of the statistics result.

Returns:

  • (Float)

    Lowest numerical value of the statistics result



130
131
132
# File 'lib/orchestrate/search/results.rb', line 130

def min
  @min
end

#statisticsHash (readonly)

Returns The statistics results.

Returns:

  • (Hash)

    The statistics results



127
128
129
# File 'lib/orchestrate/search/results.rb', line 127

def statistics
  @statistics
end

#std_devFloat (readonly)

Returns:

  • (Float)


148
149
150
# File 'lib/orchestrate/search/results.rb', line 148

def std_dev
  @std_dev
end

#sumFloat (readonly)

Returns Total of included numerical values.

Returns:

  • (Float)

    Total of included numerical values



139
140
141
# File 'lib/orchestrate/search/results.rb', line 139

def sum
  @sum
end

#sum_of_squaresFloat (readonly)

Returns:

  • (Float)


142
143
144
# File 'lib/orchestrate/search/results.rb', line 142

def sum_of_squares
  @sum_of_squares
end

#varianceFloat (readonly)

Returns:

  • (Float)


145
146
147
# File 'lib/orchestrate/search/results.rb', line 145

def variance
  @variance
end

Instance Method Details

#to_sObject Also known as: inspect

Returns Pretty-Printed string representation of the StatsResult object.

Returns:

  • Pretty-Printed string representation of the StatsResult object



168
169
170
171
# 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