I created a text index on a table “users” on a field “name”. The shell command “getIndexes” returns the following:
{
v: 2,
key: { _fts: 'text', _ftsx: 1 },
name: 'name_text',
sparse: true,
weights: { name: 1 },
default_language: 'english',
language_override: 'language',
textIndexVersion: 3
}
I’m confused why the following query gives me the error:
MongoServerError: 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
I do not have multiple text indexes on my collection – just one.
This is exactly what my input is:
const searchRes = db
.collection('users')
.find({ $text: { $search: 'hi' } });
Which is exactly what the documentation says to do
More details: I’m using serverless so Atlas Search is not supported, so I’m doing a self-managed deployment (using SST). This query works perfectly well in my mongoDB Compass shell, just not from my node.js driver.
Thank you for your time!