Missing edges in Dgraph

I’m on Dgraph v1.0.8 single node setup (zero, server, ratel all on the same node),
I’ve started zero using:

dgraph zero

I started the server using:

dgraph server --lru_mb 2048 --zero localhost:5080 --my=localhost:7080

I did a live load of data using:
dgraph live -r ~/kg.rdf --zero localhost:5080 -c 1 -s ~/kg.schema

I’m running the following query on ratel post the data load:

{
var(func: eq(brand.id,1102)) {
appleUid AS uid
}

details(func:uid(appleUid)) {
category @facets(orderdesc: tCount) @facets(eq(geo, “IN”)) {
id:category.id
}
}
}

This query does not show all the edges.
I tried the load many times and it misses to show different edges each time.
I tried the bulk load too, but that doesn’t show all the edges either.

I’m posting the links to the rdf & schema files here for you to reproduce, please try to run the query yourselves and let me know how it goes.

Link to RDF

Link to schema

I think your issue may related to this thread.

Query I used:

{
var(func:	eq(brand.id,1102),first: 10000)  {
appleUid2 AS uid
}

details(func:uid(appleUid2)) {
category @facets(orderdesc: tCount, first: 10000) @facets(eq(geo, "IN")) {
#id:category.id
  uid
  expand(_all_)
}
}
  
  
var(func:	eq(brand.id,1102)) {
appleUid AS uid
}

detailsOriginal(func:uid(appleUid)) {
category @facets(orderdesc: tCount) @facets(eq(geo, "IN")) {
id:category.id
}
}
  
}

{
  "data": {
     "details": [
      {
        "category": [
          {
            "uid": "0x4e201",
            "category.id": 20538,
            "category|tCount": 11613
          },
          {
            "uid": "0x30d42",
            "category.id": 23911,
            "category|tCount": 11159
          },
          {
            "uid": "0x2e631",
            "category.id": 20906,
            "category|tCount": 4263
          },
          {
            "uid": "0x3a983",
            "category.id": 24927,
            "category|tCount": 3774
          },
          {
            "uid": "0x50911",
            "category.id": 24427,
            "category|tCount": 1958
          },
          {
            "uid": "0x493e1",
            "category.id": 23922,
            "category|tCount": 1419
          },
          {
            "uid": "0x55731",
            "category.id": 29116,
            "category|tCount": 1189
          },
          {
            "uid": "0x64191",
            "category.id": 20002,
            "category|tCount": 1044
          },
          {
            "uid": "0x186a1",
            "category.id": 23948,
            "category|tCount": 869
          },
          {
            "uid": "0x15f91",
            "category.id": 20094,
            "category|tCount": 661
          },
          {
            "uid": "0x445c1",
            "category.id": 18966,
            "category|tCount": 636
          },
          {
            "uid": "0x29811",
            "category.id": 19242,
            "category|tCount": 586
          },
          {
            "uid": "0x222e1",
            "category.id": 25931,
            "category|tCount": 520
          },
          {
            "uid": "0xea61",
            "category.id": 23079,
            "category|tCount": 471
          },
          {
            "uid": "0x4e23",
            "category.id": 24349,
            "category|tCount": 382
          },
          {
            "uid": "0x77a11",
            "category.id": 22190,
            "category|tCount": 340
          },
          {
            "uid": "0x3f7a2",
            "category.id": 17988,
            "category|tCount": 319
          },
          {
            "uid": "0x2bf21",
            "category.id": 22199,
            "category|tCount": 295
          },
          {
            "uid": "0x13881",
            "category.id": 22710,
            "category|tCount": 238
          },
          {
            "uid": "0x29812",
            "category.id": 26385,
            "category|tCount": 238
          },
          {
            "uid": "0x5f371",
            "category.id": 25010,
            "category|tCount": 232
          },
          {
            "uid": "0x11171",
            "category.id": 18412,
            "category|tCount": 209
          },
          {
            "uid": "0x11172",
            "category.id": 23672,
            "category|tCount": 184
          },
          {
            "uid": "0x668a1",
            "category.id": 27722,
            "category|tCount": 178
          },
          {
            "uid": "0x30d41",
            "category.id": 25729,
            "category|tCount": 174
          },
          {
            "uid": "0x3f7a1",
            "category.id": 19092,
            "category|tCount": 157
          },
          {
            "uid": "0x29813",
            "category.id": 24411,
            "category|tCount": 145
          },
          {
            "uid": "0x1adb1",
            "category.id": 21876,
            "category|tCount": 142
          },
          {
            "uid": "0x7532",
            "category.id": 16915,
            "category|tCount": 141
          },
          {
            "uid": "0xc352",
            "category.id": 26162,
            "category|tCount": 119
          },
          {
            "uid": "0x4e22",
            "category.id": 17983,
            "category|tCount": 116
          },
          {
            "uid": "0xc353",
            "category.id": 23490,
            "category|tCount": 104
          },
          {
            "uid": "0x38271",
            "category.id": 26024,
            "category|tCount": 102
          },
          {
            "uid": "0x7533",
            "category.id": 22410,
            "category|tCount": 97
          },
          {
            "uid": "0x3a982",
            "category.id": 19929,
            "category|tCount": 95
          },
          {
            "uid": "0x1fbd1",
            "category.id": 24859,
            "category|tCount": 84
          },
          {
            "uid": "0x4baf1",
            "category.id": 19142,
            "category|tCount": 80
          },
          {
            "uid": "0x1d4c2",
            "category.id": 19720,
            "category|tCount": 79
          },
          {
            "uid": "0x4e21",
            "category.id": 22154,
            "category|tCount": 78
          }
        ]
      }
    ],
   
  }
}

 "detailsOriginal": [
      {
        "category": [
          {
            "id": 20538,
            "category|tCount": 11613
          },
          {
            "id": 23911,
            "category|tCount": 11159
          },
          {
            "id": 20906,
            "category|tCount": 4263
          },
          {
            "id": 24927,
            "category|tCount": 3774
          },
          {
            "id": 24427,
            "category|tCount": 1958
          },
          {
            "id": 23922,
            "category|tCount": 1419
          },
          {
            "id": 29116,
            "category|tCount": 1189
          },
          {
            "id": 20002,
            "category|tCount": 1044
          },
          {
            "id": 23948,
            "category|tCount": 869
          },
          {
            "id": 20094,
            "category|tCount": 661
          },
          {
            "id": 18966,
            "category|tCount": 636
          },
          {
            "id": 19242,
            "category|tCount": 586
          },
          {
            "id": 25931,
            "category|tCount": 520
          },
          {
            "id": 23079,
            "category|tCount": 471
          },
          {
            "id": 24349,
            "category|tCount": 382
          },
          {
            "id": 22190,
            "category|tCount": 340
          },
          {
            "id": 17988,
            "category|tCount": 319
          },
          {
            "id": 22199,
            "category|tCount": 295
          },
          {
            "id": 22710,
            "category|tCount": 238
          },
          {
            "id": 26385,
            "category|tCount": 238
          },
          {
            "id": 25010,
            "category|tCount": 232
          },
          {
            "id": 18412,
            "category|tCount": 209
          },
          {
            "id": 23672,
            "category|tCount": 184
          },
          {
            "id": 27722,
            "category|tCount": 178
          },
          {
            "id": 25729,
            "category|tCount": 174
          },
          {
            "id": 19092,
            "category|tCount": 157
          },
          {
            "id": 24411,
            "category|tCount": 145
          },
          {
            "id": 21876,
            "category|tCount": 142
          },
          {
            "id": 16915,
            "category|tCount": 141
          },
          {
            "id": 26162,
            "category|tCount": 119
          },
          {
            "id": 17983,
            "category|tCount": 116
          },
          {
            "id": 23490,
            "category|tCount": 104
          },
          {
            "id": 26024,
            "category|tCount": 102
          },
          {
            "id": 22410,
            "category|tCount": 97
          },
          {
            "id": 19929,
            "category|tCount": 95
          },
          {
            "id": 24859,
            "category|tCount": 84
          },
          {
            "id": 19142,
            "category|tCount": 80
          },
          {
            "id": 19720,
            "category|tCount": 79
          },
          {
            "id": 22154,
            "category|tCount": 78
          }
        ]
      }
    ]

@MichelDiz My issue is not related to the post you tagged, I miss nodes irrespective of whether I enable sorting or not. I’m supposed to get 50 nodes in the result. I currently get only 40 nodes in the result. Both queries you posted result only in 40 edges (instead of 50).

Fair enough. So we have to do the most obvious, analyze the RDF line by line… And compare with what was actually written.

You have 98 writes with "<category>" predicate. And have 74 predicates with <category.id>

Asking for
search(func: has(category.id))
We found Found 74 nodes

Asking for

  search(func:	has(brand.id)) {
    uid
    category {uid expand(_all_)}
}

We found 75 nodes and 74 edges.

In the original RDF you have 98 writes with “tCount” Edge atribute. But in Dgraph has only 74.

_:brand-1102 <category> _:category-23902 (tCount=1877, sCount=9, geo="IN") .
_:brand-1102 <category> _:category-23902 (tCount=6785, sCount=59, geo="US") .

So, what are you doing? you are overwriting the same edge 2 times.
You cannot use the same predicate and the same Child
_:Blank_Node and expects create two children in the same batch.

Actually not even other way, if you make UID to UID, it will have overwrite the same way. Because the relationship “parent to child” is unique. You have to use other predicate tho. One edge can’t have two differents Facets at once.

98 - 24 = 74

See below what you’re repeating. There are 24 overwrites.

_:category-27717 used 2 times
_:category-23079 used 2 times
_:category-22710 used 2 times
_:category-20094 used 2 times
_:category-26162 used 2 times
_:category-17677 used 2 times
_:category-16915 used 2 times
_:category-25931 used 2 times
_:category-19242 used 2 times
_:category-22199 used 2 times
_:category-20906 used 2 times
_:category-17881 used 2 times
_:category-23902 used 2 times
_:category-27719 used 2 times
_:category-23486 used 2 times
_:category-17988 used 2 times
_:category-23922 used 2 times
_:category-19142 used 2 times
_:category-20538 used 2 times
_:category-24427 used 2 times
_:category-22109 used 2 times
_:category-27718 used 2 times
_:category-25310 used 2 times
_:category-22953 used 2 times

Cheers.

You’re right, I was wrongly assuming that both edges would be present as they were loaded with different facet values. Thanks.