asami 2023-03-10

Is there a concise way of finding nodes with a specific node as grandparent? (parent and/or grandparent works for my specific thing) 🙂

:find ?node
:where [?node :parent ?p][?p :parent *specific*node*]

:find ?node
:where (or (and [?node :parent ?p] [?p :parent *specific*node*]) [?node :parent *specific*node])

The second one is the one where you’re looking for the parent or grandparent

If you want more concise, then I need to finish my SPARQL implementation

Of course, *specific*node* would be set up according to your context. Literal syntax, or a variable bound via :in, etc

All good, thanks a lot. I was looking at the docs for transitive attributes, and others, and was thinking there was a shortcut for specifying the max path allowed for whatever. 😄

Ah… there is no way to specify the maximum non-looped path, sorry. It wouldn’t be hard to add to the algorithm, but adding to the query syntax is tricky!