助けが必要な問題がありますが、身近に感じています。これにはリチウムが含まれ、MongoDBコードは次のようになります:http: //pastium.org/view/0403d3e4f560e3f790b32053c71d0f2b
$db = PopularTags::connection();
$map = new \MongoCode("function() {
if (!this.saved_terms) {
return;
}
for (index in this.saved_terms) {
emit(this.saved_terms[index], 1);
}
}");
$reduce = new \MongoCode("function(previous, current) {
var count = 0;
for (index in current) {
count += current[index];
}
return count;
}");
$metrics = $db->connection->command(array(
'mapreduce' => 'users',
'map' => $map,
'reduce' => $reduce,
'out' => 'terms'
));
$cursor = $db->connection->selectCollection($metrics['result'])->find()->limit(1);
print_r($cursor);
/**
User Data In Mongo
{
"_id" : ObjectId("4e789f954c734cc95b000012"),
"email" : "example@bob.com",
"saved_terms" : [
null,
[
"technology",
" apple",
" iphone"
],
[
"apple",
" water",
" beryy"
]
] }
**/
私は彼らが検索するユーザー貯蓄用語を持っています、そしてそれから私は最も人気のある用語を取得しようとします、しかし私はメッセージ'MongoDB :: __construct(invalidname'で:Uncaughtexception'Exception'のようなエラーを受け取り続けます。これまたはいくつかの方向を行う方法は?