Query, Reverse Edge Filter By Type fail

I have a schema with

parent_tree [uid] @reverse

and I ran a query:

{
  tree( func:uid(0xb303e) )
  {
     name
     ~parent_tree 
     {
       uid
      dgraph.type
      name
     }
  }
}

And it works where the dgraph.type is “Defect”

But when I ran a similar query with a type filter:

{
  tree( func:uid(0xb303e) )
  {
     name
     ~parent_tree @filter(type(Defect))
     {
       uid
      dgraph.type
      name
     }
  }
}

It returns blank for the predicate ~parent_tree

Originally this query works when there is only one uid in parent_tree, but when I added a second uid to become [ uid_1, uid_2 ] in the predicate parent_tree. It failed to retrieve when I ran a filter.

Did I made some mistake here?

Update: Weirdly, filtering by type works for some UID but fail for some other UID. It is not clear why there is such behaviour.

Hey @M.Lau,

Could you please share what version and cluster setup of Dgraph are you using? Also, could you share some sample mutation set data and your schema so that we can try and replicate the issue on a fresh install at our end?

Ok let me prepare that info.

From Ratel UI i see my localhost:8080 dgraph v1.2.1
I only have one Zero(Community Edition) and One Alpha(v1.2.1 from Ratel U1) running on S3 EC2.
The Schema for Tree is

Type Tree{
     name 
     parent_tree
}
Type Defect{
    name string
    parent_tree
}
name: string .
parent_tree: [uid] @reverse .

Data:

set{
    <_:t_1> <name> 'tree 1' .
    <_:t_2> <name> 'tree 2' .
    <_:t_2> <parent_tree> <_:t_1> .
    <_:t_3> <name> 'tree 3' .
    <_:d_1> <name> 'd 1' .
    <_:d_1> <parent_tree> <_:t_1> .
    <_:d_1> <parent_tree> <_:t_3> .
}

The issue arises sometimes when d_1 is connect to the tree t_3.
after connecting the ~parent_tree @filter(type(Defect)) fails for t_1 and it returns blank.
at the same time ~parent_tree @filter(type(Defect)) fails for t_3 and it returns blank.

the reason for filtering by type is “tree 1”, t_1, has two type of ~parent_tree : Tree(t_2) and Defect(d_1).

Could you try this with v1.2.3 or v20.03.1 and see if you still encounter this issue?

I have exactly the same issue on v20.03.01. Help!

Ok. So to do that I was trying to export my database first. And I ran into another problem while exporting so I posted in a separate thread.

In your data, I don’t see any dgraph.type edges being stored for your data. Hence type(Defect) or for that matter any type filter won’t work. If you can share the full data on which you are trying to run this query, then I might be able to help you more. I think you need more edges like

_:d_1 <dgraph.type> "Defect" .