Class: OpenSearch::DSL::Search::Aggregations::BucketSort
- Inherits:
-
Object
- Object
- OpenSearch::DSL::Search::Aggregations::BucketSort
- Includes:
- BaseAggregationComponent
- Defined in:
- lib/opensearch/dsl/search/aggregations/pipeline/bucket_sort.rb
Overview
A parent pipeline aggregation which sorts the buckets of its parent multi-bucket aggregation.
Instance Method Summary collapse
-
#sort(*args, &block) ⇒ Sort, Hash
Add a sort clause to the search definition.
-
#to_hash ⇒ Hash
Get a hash representation of the aggregation.
Methods included from BaseAggregationComponent
Instance Method Details
#sort(*args, &block) ⇒ Sort, Hash
Add a sort clause to the search definition.
68 69 70 71 72 73 74 75 |
# File 'lib/opensearch/dsl/search/aggregations/pipeline/bucket_sort.rb', line 68 def sort(*args, &block) if !args.empty? || block @sort = Sort.new(*args, &block) self else @sort end end |
#to_hash ⇒ Hash
Get a hash representation of the aggregation.
client.search(body: s.to_hash)
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/opensearch/dsl/search/aggregations/pipeline/bucket_sort.rb', line 96 def to_hash call if @aggregations @hash[:aggregations] = @aggregations.to_hash end @hash[name].merge!(sort: @sort.to_hash) if @sort @hash end |