Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-2582

Using the mongoimport command with upserts to report separate counts for documents inserted and updated

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: mongoimport
    • None
    • 1,655

      Hi,
      I have a customer who is looking for a way when using the mongoimport command to get a read out of the number of updated records vs inserted records.

      We tried to increase the verbosity with the -vvv options, but it just spits out the record from a csv that got loaded. And it doesn't appear to change from when the record exists in the collection or doesn't exist and is updated.

      Fwiw, we did a quick test on 4.2.3 with 2 documents: one inserted and one upserted and they were both reported in the same bucket:

      $ mongoimport --file=exported.json --db=test --collection=a2 --mode=upsert
      2020-05-12T12:46:27.057+1000	connected to: mongodb://localhost/
      2020-05-12T12:46:27.058+1000	2 document(s) imported successfully. 0 document(s) failed to import.
      $
      

      Based on our documentation and our testings, it looks like we don't have any functionality to have it break it down into more detailed information at the moment. Basically, reporting upsert counts is not currently done by mongoimport.

      I've checked it with one of the local core Engineers and it seems that , in theory, the update command should report nMatched, nUpserted and nModified so this seems reasonable to ask. Therefore, could you please look into this feature request? Thank you.

            Assignee:
            Unassigned Unassigned
            Reporter:
            seunghyoung.lee@mongodb.com Seunghyoung Lee
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: