File tree 2 files changed +13
-0
lines changed
2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,13 @@ impl<T> SearchResponse<T> {
133
133
pub fn aggs ( & self ) -> Aggs {
134
134
Aggs :: new ( self . aggregations . as_ref ( ) )
135
135
}
136
+
137
+ /**
138
+ Get a reference to the raw aggregation value.
139
+ */
140
+ pub fn aggs_raw ( & self ) -> Option < & Value > {
141
+ self . aggregations . as_ref ( ) . map ( |wrapper| & wrapper. 0 )
142
+ }
136
143
}
137
144
138
145
impl < T : DeserializeOwned > IsOk for SearchResponse < T > {
Original file line number Diff line number Diff line change @@ -107,6 +107,12 @@ fn success_parse_simple_nested_aggs() {
107
107
. unwrap ( ) ;
108
108
109
109
assert_eq ! ( deserialized. aggs( ) . count( ) , 124 ) ;
110
+
111
+ let doc_count = deserialized
112
+ . aggs_raw ( )
113
+ . and_then ( |aggs| aggs[ "timechart" ] [ "buckets" ] [ 0 ] [ "doc_count" ] . as_u64 ( ) ) ;
114
+
115
+ assert_eq ! ( Some ( 101 ) , doc_count) ;
110
116
}
111
117
112
118
#[ test]
You can’t perform that action at this time.
0 commit comments