Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-5155

MapRecude weird comportment with/without query

    • Type: Icon: Question Question
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.0.2
    • Component/s: Shell
    • Labels:
      None
    • Environment:
      centOs

      Hi All,

      I've a weird comportment during mapReduce.

      On a collection with around 3 000 000 documents I run this mapreduce command :

      map = function() { 
        day = this.creationDate.getDate() + '/' + this.creationDate.getMonth() + '/' + this.creationDate.getFullYear(); 
        emit({day: day, playerId: this.playerId, rapportStatus:this.rapportStatus}, 1); 
      } 
      
      reduce = function(key, values) { 
        var count = 0; 
        for ( var i=0; i<values.length; i++ ) { count = count+1; } 
        return count; 
      } 
      
      > db.report.mapReduce(map,reduce,{out: 'stats6'}) 
      { 
              "result" : "stats6", 
              "timeMillis" : 366532, 
              "counts" : { 
                      "input" : 3047542, 
                      "emit" : 3047542, 
                      "reduce" : 708187, 
                      "output" : 97182 
              }, 
              "ok" : 1, 
      } 
      

      Then I run the following find command :

      > db.stats6.find({'_id.playerId':'01426c26936541bca795309a01e4be53', '_id.day':'1/0/2012'}) 
      { "_id" : { "day" : "1/0/2012", "playerId" : "01426c26936541bca795309a01e4be53", "rapportStatus" : "INFOS" }, "value" : 31 } 
      { "_id" : { "day" : "1/0/2012", "playerId" : "01426c26936541bca795309a01e4be53", "rapportStatus" : "WARN" }, "value" : 1 } 
      

      this value are false.
      But when running the same mapReduce with a query like following :

      > db.report.mapReduce(map,reduce,{query : {'playerId':'01426c26936541bca795309a01e4be53'}, out:'stats7'}) 
      { 
              "result" : "stats7", 
              "timeMillis" : 533, 
              "counts" : { 
                      "input" : 5014, 
                      "emit" : 5014, 
                      "reduce" : 185, 
                      "output" : 97182 
              }, 
              "ok" : 1, 
      } 
      

      I've got differents results (which are actually good)

      > db.stats7.find({'_id.playerId':'01426c26936541bca795309a01e4be53', '_id.day':'1/0/2012'}) 
      { "_id" : { "day" : "1/0/2012", "playerId" : "01426c26936541bca795309a01e4be53", "rapportStatus" : "INFOS" }, "value" : 49 } 
      { "_id" : { "day" : "1/0/2012", "playerId" : "01426c26936541bca795309a01e4be53", "rapportStatus" : "WARN" }, "value" : 1 } 
      

      Somebody can explain me why ??
      Thanks

      Damien

            Assignee:
            antoine Antoine Girbal
            Reporter:
            dviel Damien Viel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: