v5
latestOpenAPI 3.1.02026-08-025631,1012.8 MBCollection Documents
Aggregate Documents
This endpoint performs aggregation operations on documents in a collection.
**Aggregation Framework**: Provides MongoDB-style aggregation operations:
- GROUP BY: Group documents by one or more fields
- Aggregations: COUNT, SUM, AVG, MIN, MAX, COUNT_DISTINCT, etc.
- Date Operations: Truncate or extract date parts for time-series analysis
- Filtering: Pre-aggregation filters (WHERE) and post-aggregation filters (HAVING)
- Sorting & Limiting: Control result ordering and size
**Use Cases**:
- Count documents by feature type or collection
- Calculate daily/monthly processing statistics
- Analyze feature distributions and confidence scores
- Generate reports with multiple metrics
**Note**: This endpoint works with both MongoDB and Qdrant using the same interface.
The system automatically selects the appropriate aggregation provider based on
the underlying metadata store.
post/v1/collections/{collection_identifier}/documents/aggregate
Path parameters
collection_identifierstring required
The unique identifier of the collection.
The unique identifier of the collection.
Request body
Example request
{
"aggregations": [
{
"alias": "total",
"function": "count"
}
],
"description": "Count documents by collection",
"group_by": [
{
"alias": "collection",
"field": "collection_id"
}
],
"sort_by": "total",
"sort_direction": "desc"
}Response
Successful Response
Example response
{
"query_info": {
"collection_id": "my-collection",
"execution_time_ms": 32,
"pipeline_stages": 4
},
"results": [
{
"group": {
"collection": "coll_123"
},
"metrics": {
"total": 523
}
},
{
"group": {
"collection": "coll_456"
},
"metrics": {
"total": 187
}
}
],
"total_groups": 2
}