Details
-
Task
-
Resolution: Cannot Reproduce
-
Major - P3
-
None
-
None
-
None
Description
http://docs.mongodb.org/master/tutorial/text-search-in-aggregation/
It says, under "Restrictions," that a $text search can only happen once in the aggregation pipeline:
A text operator can only occur once in the stage.
This is technically true, but only because the $text search must happen first. I tried to $project first, then $text search to see if it would work, and I got an error:
> db.bible.aggregate([ { $match: {$text: { $search : "Belshazzar humbled" } } } , { $group: {_id: "$_id.chapter", count : {$sum: 1}}}] )
|
{ "_id" : "16", "count" : 1 }
|
{ "_id" : "33", "count" : 1 }
|
{ "_id" : "22", "count" : 1 }
|
{ "_id" : "3", "count" : 1 }
|
{ "_id" : "1", "count" : 1 }
|
{ "_id" : "4", "count" : 1 }
|
{ "_id" : "7", "count" : 1 }
|
{ "_id" : "36", "count" : 1 }
|
{ "_id" : "18", "count" : 1 }
|
{ "_id" : "5", "count" : 3 }
|
{ "_id" : "11", "count" : 1 }
|
{ "_id" : "10", "count" : 1 }
|
{ "_id" : "2", "count" : 3 }
|
{ "_id" : "12", "count" : 4 }
|
{ "_id" : "25", "count" : 1 }
|
{ "_id" : "32", "count" : 1 }
|
{ "_id" : "8", "count" : 1 }
|
> db.bible.aggregate([{$project: {text: 1}}, { $match: {$text: { $search : "Belshazzar humbled" } } } ] )
|
assert: command failed: {
|
"errmsg" : "exception: $match with $text is only allowed as the first pipeline stage",
|
"code" : 17313,
|
"ok" : 0
|
} : aggregate failed
|
Error: command failed: {
|
"errmsg" : "exception: $match with $text is only allowed as the first pipeline stage",
|
"code" : 17313,
|
"ok" : 0
|
} : aggregate failed
|
at Error (<anonymous>)
|
at doassert (src/mongo/shell/assert.js:11:14)
|
at Function.assert.commandWorked (src/mongo/shell/assert.js:244:5)
|
at DBCollection.aggregate (src/mongo/shell/collection.js:1098:12)
|
at (shell):1:10
|
2014-03-11T14:25:03.363-0400 Error: command failed: {
|
"errmsg" : "exception: $match with $text is only allowed as the first pipeline stage",
|
"code" : 17313,
|
"ok" : 0
|
} : aggregate failed at src/mongo/shell/assert.js:13
|
>
|