dgraph-io / dgraph

The high-performance database for modern applications
https://dgraph.io
Other
20.37k stars 1.5k forks source link

entry.xcount not allowed multiple times in same sub-query #2504

Closed roker closed 5 years ago

roker commented 6 years ago

This is the same issue as https://github.com/dgraph-io/dgraph/issues/921 by using different operation.


`root@www:/dgraph # ./dgraph version

Dgraph version : Commit SHA-1 : Commit timestamp : Branch : `

roker commented 6 years ago

Workaround until fixed, it works but it is annoying. x as count( entry.x ) y as count( entry.y ) sub1 : math( x - y ) workaround1 : entry.x @filter(uid( "0x4e3" )) workaround2 : entry.y @filter( uid( "0x4e3" )) x1 as count(workaround1) y1 as count(workaround2) sum1 : math( x1 + y1 )

manishrjain commented 5 years ago

This can be done by using blocks.

{
  var(func: anyofterms(name@en, "Blade Runner")) {
    uid
    x1 as count(name@en)
  }

  var(func: anyofterms(name@en, "Blade Runner")) {
    uid
    x2 as count(name@en @filter(uid(0x27156)))  
  }

  q(func: uid(x1, x2)) {
    sub1: math(x1 - x2)
    sum1: math(x1 + x2)
  }
}