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

upsertFields not updating

    • Type: Icon: Question Question
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.7.4
    • Affects Version/s: 1.6.4
    • Component/s: Write Ops
    • Labels:
      None
    • Environment:
      Linux ubuntu 2.6.32-25-generic #45-Ubuntu SMP Sat Oct 16 19:52:42 UTC 2010 x86_64 GNU/Linux"

      Hello, and thank-you in advance.
      1) I'm able to import a CSV file by using the following:
      mongoimport d test01 -c items --type csv --headerline item-file v1.csv

      • this file has 20 fields listed on the csv header, two of which are
        Item Number and Price.
      • the database 'test01' has a collection 'items' with an Index for
        Item Number as the key field (no duplicates).
      • requirement is to update prices wholesale by importing a concise
        file of only two fields Item Number and Price and leaving the
        remaining 18 fields as is.

      I then try the following:
      mongoimport -d test01 -c items --type csv --upsertFields "Item Number" --headerline item-file-update-v1.csv

      • with the index on Item Number I get the following:
                                          • connected to: 127.0.0.1
                                            430220/443150 97%
                                            23600 7866/second
                                            imported 24323 objects

                                          • -> no prices have been updated in the collection

      • with no index on the Item Number, I get the following:
                                          • connected to: 127.0.0.1
                                            imported 24323 objects

                                          • -> the items from the csv were inserted as new items duplicating the
                                            collection which is expected.

      • I also tried this:
        mongoimport -d test01 -c items -f "Item Number",Price --type csv --upsertFields "Item Number",Price --headerline item-file-update-v1.csv

      -> same results of prices not being updated.
      I'm not able to update the prices in the collection by using the
      second update csv file. I searched for other upsertFields examples
      but to no avail. Help on this would be very much appreciated.

      also,
      2) would there be an RoR gem that leverages mongoimport for csv file uploads?

        1. item-file-update-v1.csv
          433 kB
        2. item-file-v1.csv
          5.23 MB

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            snamikas Simon Namikas
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: