Hello forums… thanks for any assistance you could provide.
I am attempting to build a query that produces the shortest path between a specific node Skill S and any other node of a specific type “Resource”. I’d also like to return the SUM(resistance) facet value for any given path: this is the criteria for minimization.
Here’s an example query between two individual nodes. Could anyone please help me to modify the DQL to produce a query that returns the paths between Skill S and any node of type Resource?
{
S as var(func: eq(XID, "Skill/NAICS/523930"))
R1 as var(func: eq(XID, "Resource/bob_smith"))
path as shortest(from: uid(S), to: uid(R1), numpaths: 1) {
Skill.Skills @facets(resistance)
Skill.Organizations @facets(resistance)
Organization.Projects @facets(resistance)
Project.ProjectRoles @facets(resistance)
ProjectRole.Resource @facets(resistance)
}
path(func: uid(path)) {
Name
}
A1: All the links seem to work well and I can execute the query perfectly between individual Skill and Resource nodes (see code block):
{
S as var(func: eq(XID, "Skill/NAICS/54"))
R1 as var(func: eq(XID, "Resource/bob/smith"))
path as shortest(from: uid(S), to: uid(R1), numpaths: 1) {
Skill.Skills @facets(resistance)
Skill.Organizations @facets(resistance)
Skill.Resources @facets(resistance)
Organization.Projects @facets(resistance)
Project.ProjectRoles @facets(resistance)
ProjectRole.Resource @facets(resistance)
}
path(func: uid(path)) {
dgraph.type
Name
XID
}
}
A2: I’m traversing across many different types and predicates (see diagram below), though most the edges with resistance are purposefully one-directional.
Here’s my question, now:
I’m attempting to return all Resource (0…N) nodes that can be related to a single Skill node, S. Here’s what I have so far and it’s not working. There’s something about DQL execution or syntax that I’m missing (see code block):
{
S as var(func: eq(XID, "Skill/NAICS/54"))
var(func: eq(dgraph.type,"Resource")) {
uid
path as shortest(from: uid(S), to: uid, numpaths: 1) {
Skill.Skills @facets(resistance)
Skill.Resources @facets(resistance)
Skill.Organizations @facets(resistance)
Organization.Projects @facets(resistance)
Project.ProjectRoles @facets(resistance)
ProjectRole.Resource @facets(resistance)
}
path(func: uid(path)) {
Name
XID
}
}
}
This query results in an error message: “line 8 column 30: Expecting argument name. Got: lex.Item [11] “(” at 8:30”, which appears to be in the shortest function line of code.
Thank you again for any advice you could offer.
JK