MongoDB Aggregation $text search fails with none existing collection in the error returned in Node.js

I’m encountering a very strange issue after switching a MongoDB aggregation pipeline from using $regex to a more efficient $text search. My application code is correct, but the server returns an error for a collection that doesn’t exist anywhere in my code or in MongoDB.

MongoDB Community version: 8.2.0

MongoDb driver: “^6.18.0”

The aggregation the pipeline
return [ { $match: { $text: { $search: "some string" } } }, { $project: { /* ... fields ... */ } } ];

This pipeline is executed against my regions collection.

The Problem:
When I run this code, it fails with the following MongoServerError:

MongoServerError: error processing query: ns=bv.regionsTree: … planner returned error :: caused by :: need exactly one text index for $text query

There is no regionsTree collection anywhere in my database, the string does appear anywhere in my code as well

Read more here: Source link