For example:
A follows C, and B also follows C, so how to find out who A and B are following together?
1 Like
in DQL:
first you query and get the UID’s of all sites that A is following
then you query and get the UID’s of all sites that B is following
and then you intersect them with the UID’s of the sites that B is following
https://dgraph.io/docs/query-language/functions/#uid
don’t worry if it’s unclear, michael or someone gonna reply u here with a more detailed response. i’m still a dgraph noob
edit here are two approaches:
Query Example: “Movies containing both Angelina Jolie and Morgan Freeman sorted by name”
https://dgraph.io/docs/query-language/multiple-query-blocks/#multiple-var-blocks
{
var(func:allofterms(name@en, "angelina jolie")) {
name@en
actor.film {
A AS performance.film
}
}
var(func:allofterms(name@en, "morgan freeman")) {
name@en
actor.film {
B as performance.film @filter(uid(A))
}
}
films(func: uid(B), orderasc: name@en) {
name@en
}
}
https://dgraph.io/docs/query-language/multiple-query-blocks/#combining-multiple-var-blocks
{
var(func:allofterms(name@en, "angelina jolie")) {
name@en
actor.film {
A AS performance.film
}
}
var(func:allofterms(name@en, "morgan freeman")) {
name@en
actor.film {
B as performance.film
}
}
films(func: uid(A,B), orderasc: name@en) @filter(uid(A) AND uid(B)) {
name@en
}
}
1 Like