Collection Documents
Aggregate Documents
Changed onThis 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
**Counting documents that match a filter**: omit group_by and send only count
aggregations, for example
`{"aggregations": [{"function": "count", "alias": "total"}], "filters": {...}}`.
The response holds one row whose metrics carry the exact number of matching
documents (an empty `group`). This is the same count documents/list returns in
`pagination.total` when you send `"include_total": true`. Any other
aggregation needs at least one group_by field.
**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
**Group values**: a group_by value comes back as a JSON number or boolean when the
namespace declares a payload index of type integer, float or bool on the field. Any
other field, including an undeclared numeric one, groups as strings.
**Note**: This endpoint works with both MongoDB and the vector store 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
Request
- Base URLhttps://api.mixpeek.com
- AuthHTTP bearer and API key in header X-Namespace
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Path parameters
collection_identifierstring required
The unique identifier of the collection.
Request body
Example request
{
"aggregations": [
{
"alias": "total",
"function": "count"
}
],
"description": "Count documents matching a filter",
"filters": {
"metadata.status": "active"
}
}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
}Changes
- info
the request property
became optional
- info
- warning
removed the optional property
from the response with the status - info
added the non-success response with the status
- info
added the non-success response with the status
- info
added the optional property
to the response with the status - info
added the required property
to the response with the status - info
added the required property
to the response with the status
- warning