D'abord, je suis nouveau sur MongoDB et j'aimerais faire de l'analyse de Big Data avec MongoDB.
Dans ma question, j'ai une collection MonogoDB avec les données suivantesMongoDB MapReduce Composite Numéro de clé
db.EIRLogs2.find()
{ "_id" : ObjectId("57772d1f152d447caa142fbf"), "NAME" : "Kamal", "AGE" : 20, "MARKS" : 100 }
{ "_id" : ObjectId("57772d1f152d447caa142fc0"), "NAME" : "Kamal", "AGE" : 30, "MARKS" : 300 }
{ "_id" : ObjectId("57772d1f152d447caa142fc1"), "NAME" : "Sunil", "AGE" : 30, "MARKS" : 300 }
{ "_id" : ObjectId("57772d1f152d447caa142fc2"), "NAME" : "Sunil", "AGE" : 30, "MARKS" : 400 }
{ "_id" : ObjectId("57772d1f152d447caa142fc3"), "NAME" : "Kasun", "AGE" : 20, "MARKS" : 100 }
{ "_id" : ObjectId("57772d1f152d447caa142fc4"), "NAME" : "Kamal", "AGE" : 20, "MARKS" : 100 }
{ "_id" : ObjectId("57772d1f152d447caa142fc5"), "NAME" : "Kasun", "AGE" : 20, "MARKS" : 100 }
{ "_id" : ObjectId("57772d1f152d447caa142fc6"), "NAME" : "Sunimal", "AGE" : 30, "MARKS" : 100 }
{ "_id" : ObjectId("57772d1f152d447caa142fc7"), "NAME" : "Kamal", "AGE" : 20, "MARKS" : 600 }
Et je me attends à appliquer une fonction de MapReduce aux données ci-dessus définies et obtenir une réponse comme ci-dessous
{ "_id" : "Kamal", "AGE" : 20, "value" : 800 }
{ "_id" : "Kamal", "AGE" : 30, "value" : 300 }
{ "_id" : "Kasun", "AGE" : 20, "value" : 200 }
{ "_id" : "Sunil", "AGE" : 30, "value" : 700 }
{ "_id" : "Sunimal", "AGE" : 20, "value" : 100 }
je ci-dessous code pour obtenir réponse ci-dessus, mais il a renvoyé une erreur
db.EIRLogs2.mapReduce(
function() {
emit({this.NAME,this.AGE}, this.MARKS);
},
function(key,values){
return Array.sum(values)
},
{ out: "ETom" }
)
j'ai eu l'erreur suivante
Sat Jul 2 09:17:32 SyntaxError: missing : after property id (shell):1
J'apprécie fortement votre aide pour résoudre ce problème
Cela fonctionne :) Merci beaucoup – Kavinda