result of collection count function does not equals with result of aggregate count function

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • None
    • Environment:
    • ALL
    • Hide

      db.collection.count() shows 5
      but aggregate count as below shows 6

      db.runCommand(
        {
            aggregate:"collection", 
            pipeline:[
                   {
                       $group:{ _id:null, count: {$sum:1} }
                   }
            ] 
         }
      )
      
      Show
      db.collection.count() shows 5 but aggregate count as below shows 6 db.runCommand( { aggregate:"collection", pipeline:[ { $group:{ _id:null, count: {$sum:1} } } ] } )
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      evn description:
      standalone database.
      6 document data exists in collection.

      but we got two different results via pure count function and aggregate count function according to below docs.
      https://docs.mongodb.com/manual/reference/command/count/#dbcmd.count

      I'm not sure whether this is a bug or my command is wrong.

            Assignee:
            Kelsey Schubert
            Reporter:
            jacky chen
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: