I created a text index on a collection. I can query it from the MongoDB compass:
db.getCollection('test').find({$text:{$search: "apple"}})
but not from the mongodb node driver (I have the latest version, “^5.7.0”)
await db
.collection('test')
.find({
$text: { $search: 'apple' }
})
.toArray();
It throws this error:
Error: error processing query: ns=db.usersTree: TEXT : query=hi, language=english, caseSensitive=0, diacriticSensitive=0
Sort: {}
Proj: {}
planner returned error :: caused by :: need exactly one text index for $text query
Steps to reproduce:
- create new collection
- create a couple documents with a “name” field
- create a text index on the name field
- query it from the mongodb node.js driver
I’m using a serverless instance, which doesn’t support Atlas search, so just regular text search.
Please let me know if able to reproduce and if this will be addressed soon. Thank you