I’m trying to use “$searchMeta” to count documents but having trouble to do so. Here’s my query:
coll.aggregate(
[
{
"$searchMeta": {
"index": "fulltextsearch",
"range": {
"lt": ISODate("2021-10-29T21:53:43Z"),
"gt": ISODate("2021-08-29T21:53:43Z"),
"path": "create_date",
},
"count": {
"type": "total",
},
}
},
]
)
It fails with this error:
MongoServerError: Must set ‘enableSearchMeta’ to true to use ‘$searchMeta’
How do I get this to work? Thanks.