Class: Orchestrate::Search::AggregateBuilder
- Inherits:
-
Object
- Object
- Orchestrate::Search::AggregateBuilder
- Includes:
- QueryBuilderDelegator
- Defined in:
- lib/orchestrate/search/aggregate_builder.rb
Overview
Aggregate Builder object for constructing aggregate params included in a search
Instance Attribute Summary collapse
-
#aggregates ⇒ Array
readonly
Aggregate param arguments.
- #builder ⇒ QueryBuilder readonly
Aggregate Functions collapse
- #distance(field_name) ⇒ DistanceBuilder
- #range(field_name) ⇒ RangeBuilder
- #stats(field_name) ⇒ AggregateBuilder
- #time_series(field_name) ⇒ TimeSeriesBuilder
- #top_values(field_name, offset = nil, limit = nil) ⇒ AggregateBuilder
Instance Method Summary collapse
-
#initialize(builder) ⇒ AggregateBuilder
constructor
Initialize a new AggregateBuilder object.
-
#to_param ⇒ Object
Constructed aggregate string parameter for search query.
-
#to_s ⇒ Object
(also: #inspect)
Pretty-Printed string representation of the AggregateBuilder object.
Constructor Details
#initialize(builder) ⇒ AggregateBuilder
Initialize a new AggregateBuilder object
24 25 26 27 |
# File 'lib/orchestrate/search/aggregate_builder.rb', line 24 def initialize(builder) @builder = builder @aggregates = [] end |
Instance Attribute Details
#aggregates ⇒ Array (readonly)
Returns Aggregate param arguments.
20 21 22 |
# File 'lib/orchestrate/search/aggregate_builder.rb', line 20 def aggregates @aggregates end |
#builder ⇒ QueryBuilder (readonly)
17 18 19 |
# File 'lib/orchestrate/search/aggregate_builder.rb', line 17 def builder @builder end |
Instance Method Details
#distance(field_name) ⇒ DistanceBuilder
70 71 72 73 74 |
# File 'lib/orchestrate/search/aggregate_builder.rb', line 70 def distance(field_name) dist = DistanceBuilder.new(self, "#{field_name}") aggregates << dist dist end |
#range(field_name) ⇒ RangeBuilder
62 63 64 65 66 |
# File 'lib/orchestrate/search/aggregate_builder.rb', line 62 def range(field_name) rng = RangeBuilder.new(self, "#{field_name}") aggregates << rng rng end |
#stats(field_name) ⇒ AggregateBuilder
54 55 56 57 58 |
# File 'lib/orchestrate/search/aggregate_builder.rb', line 54 def stats(field_name) stat = StatsBuilder.new(self, "#{field_name}") aggregates << stat stat end |
#time_series(field_name) ⇒ TimeSeriesBuilder
78 79 80 81 82 |
# File 'lib/orchestrate/search/aggregate_builder.rb', line 78 def time_series(field_name) time = TimeSeriesBuilder.new(self, "#{field_name}") aggregates << time time end |
#to_param ⇒ Object
Returns constructed aggregate string parameter for search query.
36 37 38 |
# File 'lib/orchestrate/search/aggregate_builder.rb', line 36 def to_param aggregates.map {|agg| agg.to_param }.join(',') end |
#to_s ⇒ Object Also known as: inspect
Returns Pretty-Printed string representation of the AggregateBuilder object.
30 31 32 |
# File 'lib/orchestrate/search/aggregate_builder.rb', line 30 def to_s "#<Orchestrate::Search::AggregateBuilder collection=#{collection.name} query=#{builder.query} aggregate=#{to_param}>" end |
#top_values(field_name, offset = nil, limit = nil) ⇒ AggregateBuilder
46 47 48 49 50 |
# File 'lib/orchestrate/search/aggregate_builder.rb', line 46 def top_values(field_name, offset = nil, limit = nil) top_values = TopValuesBuilder.new(self, "#{field_name}", offset, limit) aggregates << top_values top_values end |