Class: Elasticsearch::DSL::Search::Aggregations::Composite

Inherits:
Object
  • Object
show all
Includes:
BaseAggregationComponent
Defined in:
lib/elasticsearch/dsl/search/aggregations/composite.rb

Overview

A multi-bucket aggregation that creates composite buckets from different sources.

Examples:


search do
  aggregation :things do
    composite do
      size 2000
      sources [
        { thing1: { terms: { field: 'thing1.field1' } } },
        { thing2: { terms: { field: 'thing2.field2' } } }
      ]
      after after_key
    end
  end
end

See Also:

Instance Method Summary collapse

Methods included from BaseAggregationComponent

included

Instance Method Details

#to_hash(_options = {}) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/elasticsearch/dsl/search/aggregations/composite.rb', line 36

def to_hash(_options={})
  super
  # remove :after if no value is given
  @hash[name.to_sym].delete(:after) if @hash[name.to_sym].is_a?(Hash) && @hash[name.to_sym][:after].nil?

  @hash
end