How to Optimize MongoDB Aggregation Pipeline with Keyword Search and Sorting for Large Dataset?
I am working on a Laravel project that uses MongoDB via MongoDB Atlas. I have a collection with millions of documents, and I am running a complex search query that includes keyword search, sorting, and grouping. However, the query is taking too long to execute and is not performing well. Here is the query I am using: