Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-29092

cbimport: support key generators with nested field path

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • None
    • 6.5.0
    • tools

    Description

      Currently it is not possible to generate a key from json path, only first level properties.

      The following example do not work:

      i.e.

      document

      \{
       
        “sub”: \{
       
              “id”:1234
       
        }
       
      }
      

       

      /opt/couchbase/bin/cbimport json -c cluster -u Administrator -p password -b bucket -f lines -d file:///home/user/test.json -g %sub.id%
      

      We need to support it so it would support more use cases.

       
      I’m getting an error:

      2018-03-19T11:12:47.924+02:00 ERRO: Key generation for document failed, field with sub.id does not exist in document -- jsondata.(*Parallelizer).Execute.func1() at source.go:187
      

       

      It is working if the key is flat on the first level.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            roi.katz Roi Katz added a comment -

            Patrick Varley, Any workaround for that case?

             

            roi.katz Roi Katz added a comment - Patrick Varley , Any workaround for that case?  

            The only work around is to change the data model.

            pvarley Patrick Varley added a comment - The only work around is to change the data model.

            Build couchbase-server-6.5.0-1468 contains backup commit 0da92af with commit message:
            MB-29092 Support key generators with nested field

            build-team Couchbase Build Team added a comment - Build couchbase-server-6.5.0-1468 contains backup commit 0da92af with commit message: MB-29092 Support key generators with nested field

            Build couchbase-server-6.5.0-1534 contains backup commit 6467b37 with commit message:
            MB-27676 Add ignore-field flag to cbimport

            build-team Couchbase Build Team added a comment - Build couchbase-server-6.5.0-1534 contains backup commit 6467b37 with commit message: MB-27676 Add ignore-field flag to cbimport
            thuan Thuan Nguyen added a comment -

            Verified on build 6.5.0-4757.

            [root@s44015 ~]# /opt/couchbase/bin/cbexport json -c 172.23.121.224 -u Administrator -p password -b bucket1 -o /root/data.json -f list
            Json exported to `/root/data.json` successfully
            Documents exported: 1 Documents skipped: 0
            [root@s44015 ~]# more /root/data.json 
            [{
                "sub": 
                  {
                    "id":1234
                   }
            }]
            [root@s44015 ~]# /opt/couchbase/bin/cbimport json -c 172.23.121.224 -u Administrator -p password -b bucket2 -f list -d file:///root/data.json -g %sub.id%
            Json `file:///root/data.json` imported to `http://172.23.121.224:8091` successfully
            Documents imported: 1 Documents failed: 0
            [root@s44015 ~]#  

            thuan Thuan Nguyen added a comment - Verified on build 6.5.0-4757. [root@s44015 ~]# /opt/couchbase/bin/cbexport json -c 172.23.121.224 -u Administrator -p password -b bucket1 -o /root/data.json -f list Json exported to `/root/data.json` successfully Documents exported: 1 Documents skipped: 0 [root@s44015 ~]# more /root/data.json [{     "sub":       {         "id":1234        } }] [root@s44015 ~]# /opt/couchbase/bin/cbimport json -c 172.23.121.224 -u Administrator -p password -b bucket2 -f list -d file:///root/data.json -g %sub.id% Json `file:///root/data.json` imported to `http://172.23.121.224:8091` successfully Documents imported: 1 Documents failed: 0 [root@s44015 ~]#

            People

              thuan Thuan Nguyen
              roi.katz Roi Katz
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty