Provide access to the result object after executing MapReduce command #147

Closed
epicwhale opened this Issue Aug 8, 2011 · 1 comment

Projects

None yet

2 participants

@epicwhale

When a MapReduce is performed in MongoDb, it returns some very useful and important statistics about the command execution like time taken, input, emit, output (look at the example output below). The ODM has completely hidden access to this result object. It would be a good feature to give access to this result object.

Read more on result object here: http://www.mongodb.org/display/DOCS/MapReduce#MapReduce-Resultobject

Example Result Object

array
  'result' => string 'tmp.mr.ActiveUsers_foo' (length=22)
  'timeMillis' => int 194
  'counts' => 
    array
      'input' => int 1431
      'emit' => int 1431
      'output' => int 1064
  'ok' => float 1
@jwage
Member
jwage commented Jan 4, 2014

You can use ArrayIterator::getCommandResult() for this.

$qb = $this->dm->createQueryBuilder('Documents\Ecommerce\ConfigurableProduct')
    ->mapReduce($map, $reduce);
$query = $qb->getQuery();
$cursor = $query->execute();
$result = $cursor->getCommandResult();

$result will be the raw result of the map reduce command.

@jwage jwage closed this Jan 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment