|
The same thing happens with views:
db.c.insert({msg: 'hi'})
|
db.c.createIndex({'$**': 'text'})
|
db.createView('v', 'c', [{$facet:{docs:[]}}])
|
db.v.aggregate({$match:{$text:{$search:'hi'}}})
|
uncaught exception: Error: command failed: {
|
"ok" : 0,
|
"errmsg" : "$match with $text is only allowed as the first pipeline stage",
|
"code" : 17313,
|
"codeName" : "Location17313"
|
} with original command request: {
|
"aggregate" : "v",
|
"pipeline" : [
|
{
|
"$match" : {
|
"$text" : {
|
"$search" : "hi"
|
}
|
}
|
}
|
],
|
"cursor" : {
|
|
},
|
"lsid" : {
|
"id" : UUID("c6d0fccb-b99f-4f37-ab6e-1295ab9ea856")
|
}
|
}
|
Although you get a different message when you use .find():
db.v.find({$text:{$search:'hi'}})
|
Error: error: {
|
"ok" : 0,
|
"errmsg" : "text index required for $text query (no such collection 'test.v')",
|
"code" : 27,
|
"codeName" : "IndexNotFound"
|
}
|
|