File tree 1 file changed +32
-0
lines changed
lib/elasticsearch/dsl/search/aggregations/pipeline
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,19 @@ module Aggregations
44
44
class BucketSort
45
45
include BaseAggregationComponent
46
46
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
47
60
def sort ( *args , &block )
48
61
if !args . empty? || block
49
62
@sort = Sort . new ( *args , &block )
@@ -53,6 +66,25 @@ def sort(*args, &block)
53
66
end
54
67
end
55
68
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
56
88
def to_hash
57
89
call
58
90
You can’t perform that action at this time.
0 commit comments