2626 >>> print(stats)
2727"""
2828
29- from typing import TYPE_CHECKING , Optional , Dict , Any , cast
29+ from typing import TYPE_CHECKING , Optional , Dict , Any , List , cast
3030from collections import defaultdict
3131
3232from chromadb .api .types import Where
@@ -121,7 +121,9 @@ def detach_statistics_function(
121121
122122
123123def get_statistics (
124- collection : "Collection" , stats_collection_name : str , key : Optional [str ] = None
124+ collection : "Collection" ,
125+ stats_collection_name : str ,
126+ keys : Optional [List [str ]] = None ,
125127) -> Dict [str , Any ]:
126128 """Get the current statistics for a collection.
127129
@@ -131,8 +133,8 @@ def get_statistics(
131133 Args:
132134 collection: The collection to get statistics for
133135 stats_collection_name: Name of the statistics collection to read from.
134- key : Optional metadata key to filter statistics for. If provided,
135- only returns statistics for that specific key .
136+ keys : Optional list of metadata keys to filter statistics for. If provided,
137+ only returns statistics for those specific keys .
136138
137139 Returns:
138140 Dict[str, Any]: A dictionary with the structure:
@@ -198,11 +200,9 @@ def get_statistics(
198200 summary : Dict [str , Any ] = {}
199201
200202 offset = 0
201- # When filtering by key , also include "summary" entries to get total_count
203+ # When filtering by keys , also include "summary" entries to get total_count
202204 where_filter : Optional [Where ] = (
203- cast (Where , {"$or" : [{"key" : key }, {"key" : "summary" }]})
204- if key is not None
205- else None
205+ cast (Where , {"key" : {"$in" : keys + ["summary" ]}}) if keys is not None else None
206206 )
207207
208208 while True :
0 commit comments