Mongo Atlas release a native search feature that allows devs to add search to their applications (very quickly). Unfortunately, from what I can see, it is not yet supported by Meteor's Mongo driver.
Creating a cluster with a collection of sample data and the relevant search indexes (using the Atlas GUI)
Running the below code on a non-Meteor node app to ensure it is working okay:
const MongoClient = require('mongodb').MongoClient;
const uri = <MongoURL>
const client = new MongoClient(uri, { useNewUrlParser: true });
client.connect(async (err) => {
try {
const res = await client
.db('meteor')
.collection('notifications')
.aggregate([
{
$search: {
text: {
query: 'event',
path: 'title',
},
},
},
])
.toArray();
console.log(res); // Logs a list of search result documents
console.log(`${res.length} results`);
} catch (error) {
console.error(error);
}
client.close();
});
Running the same code within Meteor (getting the error described) - and I know that the aggregate pipeline works with other operators because I tested out $match:
Mongo Atlas release a native search feature that allows devs to add search to their applications (very quickly). Unfortunately, from what I can see, it is not yet supported by Meteor's Mongo driver.
The below is from my comment in the forums:
---javascript
Trying to experiment with it to replace some in-code search processes we have that are getting a bit slow as our collection grows.
For some reason though, I keep getting an error:
MongoError: Unrecognized pipeline stage name: '$search'
I tested this out by doing the following:
I think this would be a useful feature to have and that the proportion of Meteor devs who use Atlas is high.
Thanks in advance!