I am afraid this did not work either. Here is my js:
var db = connect("localhost:27017/mongo_hadoop");
var compareCollections = function(){
var cursor = db.yield_historical.out.find();
var uniqueids = new Array();
while (cursor.hasNext()) {
var thearr2 = cursor.next().ids;
thearr = thearr2.toString();
var elements = thearr.split(",");
for (var i = 0; i < elements.length; i++) {
if (uniqueids.indexOf(elements[i]) == -1) {
uniqueids.push(elements[i]);
}
}
} //loop over cursor
for (var i = 0; i < uniqueids.length; i++) {
printjson("unique ids element " + i + " is " + uniqueids[i]);
var thenewstr = '';
var cursor2 = db.yield_historical.out.find( {ids : uniqueids[i] });
while (cursor2.hasNext()) {
var thestr = cursor2.next()._id;
thenewstr = thenewstr + ' ' + thestr;
}
printjson(thenewstr);
}
};
db.eval(compareCollections);
When I did: