@@ -90,6 +90,19 @@ impl From<IntermediateKey> for Key {
9090
9191impl Eq for IntermediateKey { }
9292
93+ impl std:: fmt:: Display for IntermediateKey {
94+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
95+ match self {
96+ IntermediateKey :: Str ( val) => f. write_str ( val) ,
97+ IntermediateKey :: F64 ( val) => f. write_str ( & val. to_string ( ) ) ,
98+ IntermediateKey :: U64 ( val) => f. write_str ( & val. to_string ( ) ) ,
99+ IntermediateKey :: I64 ( val) => f. write_str ( & val. to_string ( ) ) ,
100+ IntermediateKey :: Bool ( val) => f. write_str ( & val. to_string ( ) ) ,
101+ IntermediateKey :: IpAddr ( val) => f. write_str ( & val. to_string ( ) ) ,
102+ }
103+ }
104+ }
105+
93106impl std:: hash:: Hash for IntermediateKey {
94107 fn hash < H : std:: hash:: Hasher > ( & self , state : & mut H ) {
95108 core:: mem:: discriminant ( self ) . hash ( state) ;
@@ -105,6 +118,21 @@ impl std::hash::Hash for IntermediateKey {
105118}
106119
107120impl IntermediateAggregationResults {
121+ /// Returns a reference to the intermediate aggregation result for the given key.
122+ pub fn get ( & self , key : & str ) -> Option < & IntermediateAggregationResult > {
123+ self . aggs_res . get ( key)
124+ }
125+
126+ /// Removes and returns the intermediate aggregation result for the given key.
127+ pub fn remove ( & mut self , key : & str ) -> Option < IntermediateAggregationResult > {
128+ self . aggs_res . remove ( key)
129+ }
130+
131+ /// Returns an iterator over the keys in the intermediate aggregation results.
132+ pub fn keys ( & self ) -> impl Iterator < Item = & String > {
133+ self . aggs_res . keys ( )
134+ }
135+
108136 /// Add a result
109137 pub fn push ( & mut self , key : String , value : IntermediateAggregationResult ) -> crate :: Result < ( ) > {
110138 let entry = self . aggs_res . entry ( key) ;
@@ -639,6 +667,21 @@ pub struct IntermediateTermBucketResult {
639667}
640668
641669impl IntermediateTermBucketResult {
670+ /// Returns a reference to the map of bucket entries keyed by [`IntermediateKey`].
671+ pub fn entries ( & self ) -> & FxHashMap < IntermediateKey , IntermediateTermBucketEntry > {
672+ & self . entries
673+ }
674+
675+ /// Returns the count of documents not included in the returned buckets.
676+ pub fn sum_other_doc_count ( & self ) -> u64 {
677+ self . sum_other_doc_count
678+ }
679+
680+ /// Returns the upper bound of the error on document counts in the returned buckets.
681+ pub fn doc_count_error_upper_bound ( & self ) -> u64 {
682+ self . doc_count_error_upper_bound
683+ }
684+
642685 pub ( crate ) fn into_final_result (
643686 self ,
644687 req : & TermsAggregation ,
0 commit comments