Hello people, I just started using mongo few days ago and I have a problem that I can’t find a solution
The steps that I followed are:
- I created my pipeline using MongoDB Compass first and it worked!, here is my pipeline:
[
{
$search: {
index: "search_queryString",
compound: {
must: [
{
text: {
query: "123",
path: "organization_id",
},
},
{
range: {
path: "created_at",
gte: ISODate('2024-01-01T00:00:00Z'),
lte: ISODate('2024-06-01T00:00:00Z'),
},
},
],
},
sort: { created_at: -1 },
},
}
]
- I created my code using php but when I use php I get some weird error, here is my pipeline generated with php:
[
{
$search: {
index: "search_queryString",
compound: {
must: [
{
text: {
query: "123",
path: "organization_id",
},
},
{
range: {
path: "created_at",
gte: {
$date: {
$numberLong: "1720249200",
},
},
lte: {
$date: {
$numberLong: "1723100399",
},
},
},
},
],
},
sort: { created_at: -1 },
},
}
]
as you see the only one thing that’s replaced is the ISODate, it’s getting replaced with a BSON object and this is normal of course
but the problem is that this query is not working, for some reason when I try to run this pipeline the PlanExecutor returns me an error because is asking for a type, here is the error