Facets : Edge attributes

Dgraph supports facets — key value pairs on edges — as an extension to RDF triples. That is, facets add properties to edges, rather than to nodes. For example, a friend edge between two nodes may have a boolean property of close friendship. Facets can also be used as weights for edges.

More details about Facets you can find in our Docs: https://docs.dgraph.io/query-language/#facets-edge-attributes

Reading all the documentation about Facets you will have examples of:

  • Facets on scalar predicates
  • Alias with facets
  • Facets on UID predicates
  • Filtering on facets
  • Sorting using facets
  • Assigning Facet values to a variable
  • Facets and Variable Propagation
  • Facets and Aggregation

For JSON mutation with Facets see: https://docs.dgraph.io/mutations/#facets

Run this mutation on you terminal, before running the query:

Add multiple attributes to a third single node

Sometimes you need two Edges with distinct predicates pointing to the same node. This feature can be used to “explain the relationship” of nodes.

Let’s say You have a existing Node that’s your target his UID is “0x0f43”. So you need to setup your RDF like this.

_:MyNode <predicate1> <0x0f43> ( foo=bar, and=1 ) .
_:MyNode <predicate2> <0x0f43> ( bar=bar, and=2 ) .
_:MyNode <predicate3> <0x0f43> ( bar=bar, and=3 ) .

more example:

If you do the same mutation above but using the same predicates instead of unique one. You gonna override the Edge attribute. Line by line. So you must to use distinct predicates.

Endpoint: /query
Response