Skip to content

Commit 22ca2b7

Browse files
committed
[DSL] Add documentation to methods in bucket_sort
1 parent ea89f20 commit 22ca2b7

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

lib/elasticsearch/dsl/search/aggregations/pipeline/bucket_sort.rb

+32
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ module Aggregations
4444
class BucketSort
4545
include BaseAggregationComponent
4646

47+
# Add a sort clause to the search definition.
48+
#
49+
# @example
50+
#
51+
# bucket_sort do
52+
# sort do
53+
# by :total_sales, order: 'desc'
54+
# end
55+
# end
56+
#
57+
# @return [ Sort, Hash ] The sort definition.
58+
#
59+
# @since 0.1.9
4760
def sort(*args, &block)
4861
if !args.empty? || block
4962
@sort = Sort.new(*args, &block)
@@ -53,6 +66,25 @@ def sort(*args, &block)
5366
end
5467
end
5568

69+
# Get a hash representation of the aggregation.
70+
#
71+
# @example
72+
#
73+
# s = search do
74+
# aggregation do
75+
# bucket_sort do
76+
# sort do
77+
# by :total_sales, order: 'desc'
78+
# end
79+
# end
80+
# end
81+
# end
82+
#
83+
# client.search(body: s.to_hash)
84+
#
85+
# @return [ Hash ] The hash representation of the aggregation.
86+
#
87+
# @since 0.1.9
5688
def to_hash
5789
call
5890

0 commit comments

Comments
 (0)