how to use map-reduce ?

閲覧: 703 回
最初の未読メッセージにスキップ

tasyjean sozoran

未読、
2013/07/13 22:44:382013/07/13
To: reacti...@googlegroups.com
Hi

is map-reduce supported in version .9 ? if so how to use it ?


Thanks!

Cheers,
Tasyjean

Mark van der Tol

未読、
2013/07/15 9:40:112013/07/15
To: reacti...@googlegroups.com
Hi,

There is no build-in command for MapReduce, but you can make use of the RawCommand to send commands which have no convenience method in ReactiveMongo.

The code for doing a map-reduce would look something like this:

val db: DefaultDB = …
val mapReduceCommand = BSONDocument(
  "mapreduce" -> "inputCollectionName",
  "map" -> BSONString(map),
  "reduce" -> BSONString(reduce),
  "out" -> BSONDocument("replace" -> "outputCollectionName")
)
val result = db.command(RawCommand(mapReduceCommand))

All possible parameters for the mapReduce command are specified here: http://docs.mongodb.org/manual/reference/command/mapReduce/

Mark

tasyjean sozoran

未読、
2013/07/17 9:03:452013/07/17
To: reacti...@googlegroups.com
Great ! 
thank you



Tasyjean

Loïc Descotte

未読、
2014/12/20 9:05:322014/12/20
To: reacti...@googlegroups.com
Hi, 

In the MongoDB documentation examples, map and reduce are javascript functions, for example with loops, so I'm no sure ton understand how to fill this in a BSONDocument object.
Do you have an example of mapreduce using ReactiveMongo?

Thanks
Loïc

Le mercredi 17 juillet 2013 15:03:45 UTC+2, tasyjean sozoran a écrit :
Great ! 
thank you



Tasyjean

Loïc Descotte

未読、
2014/12/23 2:18:222014/12/23
To: reacti...@googlegroups.com
I just found an example on the lichess game code (may be helpful to other people having the same question).  You just need to write a JS function String : 
全員に返信
投稿者に返信
転送
新着メール 0 件