1

New Dgraph user wondering if anyone can provide me with an example recursive count and sum query to help get me going.

The data looks like this (there are more predicates, but left out for simplicity):

{
     "uid" : <0x1>,
     "url" : "example.com",
     "link" : [
          {
               "uid" : <0x2>,
               "url" : "example2.com",
               "link" : [
                    {    
                         "uid" : <0x4>,
                         "url" : "example4.com",
                         "link" : [
                              {
                                   "uid" : <0x6>,
                                   "url" : "example6.com",
                                   "link" : [ 
                                        {
                                             etc...
                                        }
                                   ]
                              }
                         ]
                    },
                    {
                         "uid" : <0x5>,
                         "url" : "example5.com",
                    }   
               ]
          },
          {
                "uid" : <0x2>,
                "url" : "example2.com",
                "link" : [
                    {
                         etc ....
                    }    
          },
     ]
}

Just a home page with n-links which each have n-links and the depth, obviously, can vary. Just hoping for a good example of how to count all the links for each url and sum them up. I will add different filters to the query at some point, but just wanting to see a basic query to help get me going. Thanks.

six7zero9
  • 313
  • 1
  • 4
  • 15

0 Answers0