I have view map and reduce like this: Map: function(doc) { if(doc.type){ var usersLength = doc.users.length; for (var i = 0; i < usersLength ; i++) { emit([doc.users[i].userid,doc.Service....
So I have Riak running on 2 EC2 servers, using python to run javascript Mapreduce. They have been clustered. Mainly used for "proof of concept". There are 50 keys in the bucket, all the map/reduce function does is re-format the data. This i...
There is a question (and answer) that deals with the general case. I am having difficulty using a scope variable as a field key (as opposed to the field value) In the example below all the FULLY_CAPS fields are scope variables. In the case of SERVIC...
I take data from a search box and then insert into MongoDB as a document using the regular insert query. The data is stored in a collection for the word "cancer" in the following format with unique "_id". { "_id": { ...
I want to reduce this object to just an object containing product name and average price. What's the fastest way to do it? var foo = { group1: [ { name: "one", price: 100 }, { n...
I'm trying to do a simple map reduce in the Mongo shell, but the reduce function never gets called. This is my code : db.sellers.mapReduce( function(){ emit( this._id, 'Map') } , function(k,vs){ return 'Reduce' },...
I'm stuck on the following: A script is returning an arbitrary number n or array, like this: [["a"], ["b"], ["c"], ["d"]] I need to loop over the arrays using promise then(), but as I don't know how many el...
I have multiple documents with this schema, each document is per product per day: { _id:{}, app_id:'DHJFK67JDSJjdasj909', date:'2014-08-07', event_count:32423, event_count_per_type: { 0:322, 10:423...
I'm using what seems to be a common trick for creating a join view: // a Customer has many Orders; show them together in one view: function(doc) { if (doc.Type == "customer") { emit([doc._id, 0], doc); } else if (doc.Type == "...
I have a query where I need to return 10 of "Type A" records, while returning all other records. How can I accomplish this? Update: Admittedly, I could do this with two queries, but I wanted to avoid that, if possible, thinking it would be l...
©2020 All rights reserved.