I am using CouchDB and I want to use MapReduce better when querying data.
My specific use case:
I have a lot of polls. Each survey has a meter number, metric and metric readings, for example:
{ meterNumber: 1, meterReading: 2050, meterReadingDate: 1480000000000 }
Then I use the Map function, taking readings with meterNumber. There are many keys that are repeated (reading the same counter on different dates). i.e.
[ [meterNumber, {reading: xxx, readingDate: xxx}], [meterNumber, {reading: xxx, readingDate: xxx}], [meterNumber, {reading: xxx, readingDate: xxx}], etc ]
Then I group them before sending them to the reduction function, and the reduction function should actually EXPAND set the values. That is, I want this:
[ [meterNumber, [{reading:xxx, readingDate: xxx}, {reading:xxx, readingDate: xxx}, {reading:xxx, readingDate: xxx}]], [meterNumber, [{reading:xxx, readingDate: xxx}, {reading:xxx, readingDate: xxx}, {reading:xxx, readingDate: xxx}]], [meterNumber, [{reading:xxx, readingDate: xxx}, {reading:xxx, readingDate: xxx}, {reading:xxx, readingDate: xxx}]], etc ]
To run this MapReduce view on CouchDB, I had to enable this type of result set ( Couchdb - is it possible to deactivate the reduce_overflow_error error ).
This suggests that I may run into performance issues with large result sets. This is true? Why do you need to specifically enable this setting in CouchDB?
*** EDIT
The accepted answer below states that what I was doing in MapReduce was also possible (and better) using lists. Here's another good answer on the same topic: The best way to do "one to many" and "JOIN". in CouchDB
*** EDIT
Here is the link from the CouchDB documentation: http://guide.couchdb.org/draft/transforming.html