我正在try 使用多个字段进行mongodb全文搜索.
document.collection.getIndexes ()
,
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" : "document.collection"
},
{
"v" : 1,
"key" : {
"name" : 2,
"description" : 1,
"category" : 1
},
"name" : "name_2_description_1_category_1",
"ns" : "document.collection",
"background" : true,
"safe" : null
}
]
现在,如果我try 执行文本搜索,使用以下命令-
db.collection.find( {$text:{$search:'alias'}} ).limit(10)
收到以下错误消息:
error: {
"$err" : "Unable to execute query: error processing query: ns=document.collection limit=10 skip=0\nTree: TEXT : query=alias, language=, tag=NULL\nSort: {}\nProj: {}\n planner returned error: need exactly one text index for $text query",
"code" : 17007
}
我试过谷歌和mongodb文档,但什么都找不到.