MongoDB - 无法规范化查询:BadValue 未知运算符:$meta

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23639896/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 13:42:51  来源:igfitidea点击:

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

mongodb

提问by Sean McClory

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

这在 2.6.1 中发生在我身上 - 所以,如果有人陷入这个错误,我想我会写出答案。

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}

回答by Sean McClory

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' } }
);