Unknown operator $search

Hi fellows,
I am currently learning hwo tio use mongosh following this video :
MongoDB Crash Course - YouTube

Trying this: db.posts.find({text: {$search : "\Post O\""} })
I get:
MongoServerError: unknown operator: $search
What do I have to do to fix this error?

Many thanks in advnace,

The $search operator is only available through aggregation pipeline and to collections hosted on Atlas

So using db.posts.aggregate() instead of find() might help

Have further read on the docs here https://www.mongodb.com/docs/manual/reference/operator/aggregation/search/

Hello Ibrahim, Many thanks fpr you help. I swapped $search to $aggregate what worked without error but now I get :

Unrecognized pipeline stage name: 'views’
when I try : db.posts.aggregate({views: { $gte: 10 } } ).pretty()

Still searching for a solution to fix it .


To make such a query you need a $match stage.