MapReduce on two Collections using MongoDB and C# -


i have 2 collections following details:

comments

{"_id" : objectid("521588ccb5d44d23aca151a2"), "userid" : "5215862eb5d44d23aca1519d", "comment" : "hello" } {"_id" : objectid("521588ccb5d44d23aca151a3"), "userid" : "5215862eb5d44d23aca1519e", "comment" : "this cool" } 

"comment" : "hello" } {"_id" : objectid("521588ccb5d44d23aca151a4"), "userid" : "5215862eb5d44d23aca1519e", "comment" : "i mongo" }

user

{ "_id" : objectid("5215862eb5d44d23aca1519d"), "nickname" : "jane"} { "_id" : objectid("5215862eb5d44d23aca1519e"), "nickname" : "jon"} 

how achieve following using mapreduce (and best task @ hand)? collection ideally large. i.e. hundreds of thousands or millions.

{ "userid" : "5215862eb5d44d23aca1519d", "comment": "hello", "nickname" : "jane"} { "userid" : "5215862eb5d44d23aca1519e", "comment": "this cool", "nickname" : "jon"} { "userid" : "5215862eb5d44d23aca1519e", "comment": "i mongo", "nickname" : "jon"} 

bote: using mongodb .net c# drivers.

mapreduce not tool task, because mapreduce query performed on single collection. have perform mapreduce on 1 collection, , in mapping function read other. the documentation explicitely warns shouldn't this: "the reduce function should not access database, perform read operations".

mongodb in general not designed performing join-operations.

what can do:

solution a: perform join on application layer. first query comment collection , use results query user collection in second query.

solution b: store copy of authors nickname in comment documents don't have query user collection (in document-oriented databases, redundancies aren't evil in relational databases).


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -