-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
$pipeline is not a list (unexpected index: "$match") #880
Comments
Wrapping the aggregation in an array should work.
|
thanks @kevinem, now this working.... |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Hi, i am getting this error when i try to use aggregate and i am new to mongoDB. please help me out.
MongoDB shell version: V3.0.12
jenssegers/mongodb v3.0.2
mongodb/mongodb V1.0.2
$statements = $this->db->statements->aggregate(
[
'$match' => $match
],
[
'$project' => [
'year' => ['$year' => '$timestamp'],
'month' => ['$month' => '$timestamp'],
'day' => ['$dayOfMonth' => '$timestamp'],
'actor' => '$statement.actor'
]
],
[
'$group' => [
'_id' => [
'year' => '$year',
'month' => '$month',
'day' => '$day'
],
'count' => ['$sum' => 1],
'actors' => ['$addToSet' => '$actor']
]
],
[
'$sort' => ['_id' => 1]
],
[
'$project' => [
'a' => '$count',
'b' => ['$size' => '$actors'],
'y' => ['$concat' => [
[ '$substr' => [ '$_id.year', 0, 4 ] ],
'-',
[ '$cond' => [
[ '$lte' => [ '$_id.month', 9 ] ],
[ '$concat' => [
'0',
[ '$substr' => [ '$_id.month', 0, 2 ] ],
]],
[ '$substr' => [ '$_id.month', 0, 2 ] ]
]],
'-',
[ '$cond' => [
[ '$lte' => [ '$_id.day', 9 ] ],
[ '$concat' => [
'0',
[ '$substr' => [ '$_id.day', 0, 2 ] ],
]],
[ '$substr' => [ '$_id.day', 0, 2 ] ]
]]
]
],
]
]
);
[2016-07-01 09:16:17] local.ERROR: MongoDB\Exception\InvalidArgumentException: $pipeline is not a list (unexpected index: "$match") in /home/vagrant/Code/newlearning/vendor/mongodb/mongodb/src/Operation/Aggregate.php:94
Stack trace:
#0 /home/vagrant/Code/newlearning/vendor/mongodb/mongodb/src/Collection.php(186): MongoDB\Operation\Aggregate->__construct('homestead', 'statements', Array, Array)
#1 /home/vagrant/Code/newlearning/app/Locker/Data/Dashboards/BaseDashboard.php(221): MongoDB\Collection->aggregate(Array, Array, Array, Array, Array)
#2 /home/vagrant/Code/newlearning/app/Locker/Data/Dashboards/BaseDashboard.php(31): App\Locker\Data\Dashboards\BaseDashboard->getStatementNumbersByDate(Object(Carbon\Carbon), Object(Carbon\Carbon))
#3 /home/vagrant/Code/newlearning/app/Http/Controllers/SiteController.php(115): App\Locker\Data\Dashboards\BaseDashboard->getGraphData(Object(Carbon\Carbon), Object(Carbon\Carbon))
#4 [internal function]: App\Http\Controllers\SiteController->getGraphData()
#5 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(256): call_user_func_array(Array, Array)
#6 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(164): Illuminate\Routing\Controller->callAction('getGraphData', Array)
#7 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(112): Illuminate\Routing\ControllerDispatcher->call(Object(App\Http\Controllers\SiteController), Object(Illuminate\Routing\Route), 'getGraphData')
#8 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#9 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#10 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#11 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#12 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(114): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#13 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(67): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(App\Http\Controllers\SiteController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'getGraphData')
#14 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Routing/Route.php(203): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'App\Http\Contro...', 'getGraphData')
#15 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Routing/Route.php(134): Illuminate\Routing\Route->runWithCustomDispatcher(Object(Illuminate\Http\Request))
#16 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Routing/Router.php(708): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#17 [internal function]: Illuminate\Routing\Router->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#18 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#19 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#20 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#21 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Routing/Router.php(710): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#22 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Routing/Router.php(673): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#23 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Routing/Router.php(635): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#24 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(236): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#25 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http{closure}(Object(Illuminate\Http\Request))
#26 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#27 /home/vagrant/Code/newlearning/vendor/lucadegasperi/oauth2-server-laravel/src/Middleware/OAuthExceptionHandlerMiddleware.php(36): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#28 [internal function]: LucaDegasperi\OAuth2Server\Middleware\OAuthExceptionHandlerMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#29 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#30 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#31 [internal function]: Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#32 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#33 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(62): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#34 [internal function]: Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#35 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#36 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#37 [internal function]: Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#39 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#40 [internal function]: Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#41 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#42 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(44): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#43 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#44 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#45 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#46 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#47 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(122): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#48 /home/vagrant/Code/newlearning/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(87): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#49 /home/vagrant/Code/newlearning/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#50 {main}
The text was updated successfully, but these errors were encountered: