Setting data like below could assign a different/non-deterministic uid to nodes:
{
set {
_:michael <name> "Michael" .
_:michael <dgraph.type> "Person" .
_:michael <age> "39" .
_:michael <friend> _:amit .
_:amit <name> "Amit"@en .
_:amit <dgraph.type> "Person" .
_:amit <age> "35" .
_:amit <friend> _:michael .
_:amit <friend> _:sang .
}
}
Therefore do not hardcode the uids in your shortest path query, instead you could follow this:
{
var(func: eq(name, "Michael")){
SOURCE as uid
}
var(func: eq(name, "Amit")){
TARGET as uid
}
path as shortest(from: uid(SOURCE), to: uid(TARGET)) {
friend
}
path(func: uid(path)) {
name
}
}
It is possible that the hardcoded uids you provide in shortest queries are assigned to some other node. You can check that by:
{
query(func: uid("0xb")) {
name
}
}