File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -91,19 +91,21 @@ def get(self, request: HttpRequest) -> Response:
9191 serializer = self .serializer_class (response , many = True )
9292 aggregations : Dict [str , Any ] = response .aggregations .to_dict ()
9393
94- metadata_aggregations = aggregations [ "metadata" ][ "filtered_metadata" ][
95- "composite_agg"
96- ]["buckets" ]
97- aggregations . pop ( "metadata" )
98- if "catalogs" in aggregations :
99- aggregations .pop ("catalogs " )
100- for agg in metadata_aggregations :
101- label : str = agg ["key" ]["metadata_label" ]
94+ if "metadata" in aggregations :
95+
96+ metadata_aggregations = aggregations [ "metadata" ]["filtered_metadata" ][
97+ "composite_agg"
98+ ][ "buckets" ]
99+ aggregations .pop ("metadata " )
100+ for agg in metadata_aggregations :
101+ label : str = agg ["key" ]["metadata_label" ]
102102 value : str = agg ["key" ].get ("metadata_value" , "" )
103103 if label not in aggregations :
104104 aggregations [label ] = {}
105105 aggregations [label ][value ] = agg ["doc_count" ]
106106
107+ if "catalogs" in aggregations :
108+ aggregations .pop ("catalogs" )
107109 # Handle sectors aggregation (now comes as "sectors.raw")
108110 if "sectors.raw" in aggregations :
109111 sectors_agg = aggregations ["sectors.raw" ]["buckets" ]
You can’t perform that action at this time.
0 commit comments