asami

2023-03-10T13:47:11.350899Z

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

quoll 2023-03-10T14:15:13.285329Z

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

quoll 2023-03-10T14:16:59.614559Z

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

quoll 2023-03-10T14:17:43.449029Z

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

quoll 2023-03-10T14:18:24.866799Z

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

quoll 2023-03-10T14:20:21.962239Z

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

2023-03-10T14:39:13.314189Z

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. 😄

quoll 2023-03-10T16:35:48.534339Z

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!