I am getting the same error, I just created another collection and I am trying to filter by date
this is my aggregation: running on MongoDB Compass
[
{
$search: {
index: "serviceLogsIndex",
compound: {
must: [
{
text: {
query: "5bd09a7c08228b112371bdc3",
path: "organization_id",
},
},
{
range: {
path: "created_at",
gt: {
$date: {
$numberLong: "1722470400",
},
},
lt: {
$date: {
$numberLong: "1724716799",
},
},
},
},
],
},
},
},
{
$group: {
_id: "$service",
services: { $count: {} },
},
},
]
and this is my atlas index json
{
"mappings": {
"dynamic": true,
"fields": {
"created_at": {
"type": "date"
},
"organization_id": {
"type": "string"
},
"service": {
"type": "string"
}
}
}
}
I am using mongodb version 5