Spawned b/c of NODE-2162
The code below produces the error "$match with $text is only allowed as the first pipeline stage", even though $match with $text is the only pipeline stage. Is there a subtle syntax error somewhere, or what else might be going on?
const collectionChangeStream = collection.watch([ { $match: { $text: { $search: 'cake' } } }, ]); collectionChangeStream.on('change', next => { console.log(next); });
The code above results in sending a pipeline to the server that looks something like this:
[ { $changeStream: { fullDocument: 'default' } }, { $match: { $text: { $search: 'cake' } } } ]
This is a result of an implementation detail of change streams. The error message "$match with $text is only allowed as the first pipeline stage" does not clearly identify to a user what exactly went wrong, and how they can fix it.
Is it possible to have a more informative error message in this case?
- is depended on by
-
NODE-2162 MongoError: "$match with $text is only allowed as the first pipeline stage"
- Closed