Question

This happened to me in 2.6.1 - So, in case anyone wanders into this error, I thought I'd write the answer out.

This first command worked fine, but the second one didn't.

db.test.find({$text: {$search: 'york'}} )

db.test.find({$text: {$search: 'york'}, score: {$meta: 'textScore'}} )

and threw up the error below

{"$err": "Can't canonicalize query: BadValue unknown operator: $meta", "code": 17287}
Was it helpful?

Solution

Turns out I just had the brackets in the wrong place.. and it should have read.

//This works
db.test.find(
    { $text: { $search: 'york' } },
    { score: { $meta: 'textScore' } }
);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top