Class: Orchestrate::Search::TopValuesBuilder

Inherits:
Object
  • Object
show all
Includes:
AggregateBuilderDelegator, QueryBuilderDelegator
Defined in:
lib/orchestrate/search/aggregate_builder.rb

Overview

Stats Builder object for constructing top-values functions to be included in the aggregate param

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(builder, field_name, offset = nil, limit = nil) ⇒ TopValuesBuilder

Initialize a new TopValuesBuilder object If omitted, uses the server default value of zero. If omitted, uses the server default value of ten.

Parameters:

  • builder (AggregateBuilder)

    The Aggregate Builder object

  • field_name (#to_s)

    The field to operate over

  • offset (Integer, nil) (defaults to: nil)

    The zero-based index of the first paged value to retrieve in this aggregation.

  • limit (Integer, nil) (defaults to: nil)

    The maximum number of values to retrieve per page of results for this aggregation.


104
105
106
107
108
109
110
111
112
# File 'lib/orchestrate/search/aggregate_builder.rb', line 104

def initialize(builder, field_name, offset=nil, limit=nil)
  @builder = builder
  @field_name = field_name
  if offset.nil? ^ limit.nil?
    raise ArgumentError, "offset and limit arguments can only be supplied together, or not at all"
  end
  @offset = offset
  @limit = limit
end

Instance Attribute Details

#builderAggregateBuilder (readonly)

Returns:


92
93
94
# File 'lib/orchestrate/search/aggregate_builder.rb', line 92

def builder
  @builder
end

#field_name#to_s (readonly)

Returns The field to operate over.

Returns:

  • (#to_s)

    The field to operate over


95
96
97
# File 'lib/orchestrate/search/aggregate_builder.rb', line 95

def field_name
  @field_name
end

Instance Method Details

#to_param#to_s

Returns constructed aggregate string clause.

Returns:

  • (#to_s)

    constructed aggregate string clause


121
122
123
124
125
126
127
# File 'lib/orchestrate/search/aggregate_builder.rb', line 121

def to_param
  if @offset.nil? && @limit.nil?
    "#{@field_name}:top_values"
  else
    "#{@field_name}:top_values:offset:#{@offset}:limit:#{@limit}"
  end
end

#to_s#to_s Also known as: inspect

Returns Pretty-Printed string representation of the TopValuesBuilder object.

Returns:

  • (#to_s)

    Pretty-Printed string representation of the TopValuesBuilder object


115
116
117
# File 'lib/orchestrate/search/aggregate_builder.rb', line 115

def to_s
  "#<Orchestrate::Search::TopValuesBuilder collection=#{collection.name} field_name=#{@field_name} offset=#{@offset} limit=#{@limit}>"
end