SPARQL recursive ancestor query

醉酒当歌 提交于 2019-12-07 09:18:27

问题


I'm stuck with a recursive query in SPARQL, I cant wrap my head around it. I want to get all ancestors of an instance "a" (a hasParent b, b hasParent c, c hasParent d) so the result would be "b, c ,and d" if instance is "a".

Any ideas how to construct the linked part where parent has a parent which has another parent? (The depth of the recursion is not known)


回答1:


See SPARQL property paths and operator +.

SELECT *
{ <a> <hasParent>+ ?ancestor }


来源:https://stackoverflow.com/questions/41573900/sparql-recursive-ancestor-query

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!