What does " filtering on value edge is not supported" mean?

https://dgraph.io/docs/query-language/#filtering-on-list says

" Dgraph supports filtering based on the list. Filtering works similarly to how it works on edges and has the same available functions.

For example, @filter(eq(occupations, "Teacher")) at the root of the query or the parent edge will display all the occupations from a list of each node in an array but will only include nodes which have Teacher as one of the occupations. However, filtering on value edge is not supported."

I am new to dgraph. Can you please help me understand what does “filtering on value edge is not supported.” mean?

The edge can be of the following types:
type1: object → predicate
type2: object → object

We apply filter on some edge or on the root of the query. Consider the following example:

{
  name
  friend @filter(eq(name, "Akash")) {
    name 
  }
}

In the above example friend is an edge of type2, while name is an edge of type1. We can apply filter on edge of type2 but not on type1 (value edge).

So something like this is not allowed:

{
  name @filter(eq(name, "Akash"))
  friend {
    name 
  }
}
1 Like

Hi Tamalsaha,

Well, Dgraph has the concept of edges and predicates. They are technically the same. Synonymous. The sense of predicate is the same grammatical sense (That is, any value of a node is a predicate, whether it is a connection or a value). And generally “edge” we refer abstractly to any node value as well. So we use “Vale edge” instead of simply “edge”.

Edges are generally a connection between two points (as in geometry and mathematics), but when we say “Value Edge” we are referring to a specific edge that does not create a relationship between N nodes, but stores information in a Scalar Type.

So, going back to the documentation point. It says that it is not possible to use filters that are specific to edges in node relations. You can only have the value edge as a reference for a query at the root and not within the body of the query. Because that value edge is not a relationship between nodes. Only, in that case, you can use the filter.

Cheers.

2 Likes

I think it might be worth changing that sentence to clarify that it is possible to filter value edges at root level for that node.

Not sure, I think the whole query language with time will be self-explanatory.
For example, in the same context of filtering value edges - Taking Ahsan’s example:
Instead of doing this

{
  name @filter(eq(name, "Akash"))
  friend {
    name 
  }
}

The user should know already that he should use like this

{
  q(func: eq(name, "Akash")) {
    name 
    friend {
      name 
    }
  }
}

Cuz the first query makes no sense. And is also missing the query root.

2 Likes