Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB - Can't canonicalize query: BadValue unknown operator: $meta

Tags:

mongodb

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}
like image 476
Sean McClory Avatar asked May 13 '14 19:05

Sean McClory


1 Answers

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' } }
);
like image 105
Sean McClory Avatar answered Oct 11 '22 13:10

Sean McClory