Class: Arelastic::Aggregations::Terms

Inherits:
Bucket show all
Defined in:
lib/arelastic/searches/terms.rb,
lib/arelastic/aggregations/terms.rb

Instance Attribute Summary collapse

Attributes inherited from Bucket

#aggs

Attributes inherited from Aggregation

#meta, #name

Instance Method Summary collapse

Methods inherited from Aggregation

#nested, #reverse_nested

Methods inherited from Nodes::Node

#==, #convert_to_elastic, #read_option!

Methods included from Arelastic::Arities::Binary

#binary

Methods included from Arelastic::Arities::Polyadic

#polyadic

Methods included from Arelastic::Arities::Unary

#unary

Constructor Details

#initialize(field, options = {}) ⇒ Terms

Returns a new instance of Terms.



6
7
8
9
# File 'lib/arelastic/searches/terms.rb', line 6

def initialize field, options = {}
  @field = field
  @options = options
end

Instance Attribute Details

#fieldObject

Returns the value of attribute field.



4
5
6
# File 'lib/arelastic/searches/terms.rb', line 4

def field
  @field
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/arelastic/searches/terms.rb', line 4

def options
  @options
end

Instance Method Details

#as_elasticObject



11
12
13
14
15
# File 'lib/arelastic/searches/terms.rb', line 11

def as_elastic
  params = {"field" => field}.update(options)

  {"terms" => params}
end

#as_elastic_aggregationObject



4
5
6
# File 'lib/arelastic/aggregations/terms.rb', line 4

def as_elastic_aggregation
  {'terms' => options}.merge(super)
end