Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-1753

map-reduce output result that is less than i supposed

    XMLWordPrintableJSON

Details

    Description

      map code:
      map = new MongoCode("function(){
      emit(333,this);
      }");
      reduce code:
      reduce = new MongoCode("function(key, values) {
      r=0;
      for(var idx=0;idx<values.length;idx++)

      { r+=1; }

      return r;
      }");
      run code:
      result = db->command(array(
      "mapreduce" => "gameLog",
      "map" => map,
      "reduce" => reduce,
      "out" => array("replace" => "gameLogResult")
      )
      );
      the run code return:
      Array
      (
      [result] => gameLogResult
      [timeMillis] => 284
      [counts] => Array
      (
      [input] => 18864
      [emit] => 18864
      [reduce] => 189
      [output] => 1
      )

      [ok] => 1
      )
      the map-reduce result is that

      { "_id" : 333, "value" : 65 }

      ,but i supposed result is that

      { "_id" : 333, "value" : 18864 }

      Who can tell me why is this,Help me!

      Attachments

        Activity

          People

            Unassigned Unassigned
            auto auto
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              10 years, 29 weeks, 2 days ago