这个 Sparql 查询有什么问题
我有一个父类“Causes”,它有子类“Agging”、“BadLifeStyle”,每个类 Causes 都有一个带有个人的数据类型属性“name”(Class=>Individuals) Causes => Cause_1,老化 => Agging_1,BadLifeStyle =>不良生活方式_1 我想得到这样的结果
Ind SubCLassOF type
Agging_1 Causes Agging
BadLifeStyle_1 Causes BadLifeStyle
Cause_1 Causes
我写了这个查询
SELECT *
WHERE {
?cause rdf:type ?typename.
?cause rdfs:subClassOf ?subClass.
OPTIONAL{?cause NS:name ?name.}
FILTER(REGEX(STR(?typename),"Causes","i")
|| REGEX(STR(?subClass),"Causes","i"))
}
它没有给我 Cause_1 个人
I have a Parent Class "Causes" which has SubClasses "Agging","BadLifeStyle" Each Class Causes has a datatype property "name" with individuals (Class=>Individuals) Causes => Cause_1,Agging => Agging_1,BadLifeStyle => BadLifeStyle_1
I want to get results like this
Ind SubCLassOF type
Agging_1 Causes Agging
BadLifeStyle_1 Causes BadLifeStyle
Cause_1 Causes
I wrote this query
SELECT *
WHERE {
?cause rdf:type ?typename.
?cause rdfs:subClassOf ?subClass.
OPTIONAL{?cause NS:name ?name.}
FILTER(REGEX(STR(?typename),"Causes","i")
|| REGEX(STR(?subClass),"Causes","i"))
}
It didnt give me Cause_1 individual
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从语法上讲,您的查询看起来不错,不确定问题是什么...
通常我更喜欢执行 UNION 对于此类操作,在我们的例子中类似于:
Syntactically your query looks fine, not sure what's the problem...
Usually I prefer to perform a UNION for such kind of operations, in our case something like:
我正在为 RDF 和 sparql 使用 virtuoso 服务器。
在 virtuoso 中,我们必须在 OPTIONAL 之前添加一个空格或输入,然后 OPTIONAL 才会在 virtuoso 中起作用。
因此,在 OPTIONAL 之前添加一个空格或输入即可获得结果。
希望这适用于此查询。
I am using virtuoso server for RDF and sparql.
In virtuoso, we have to add one space or enter before OPTIONAL then OPTIONAL will work in virtuoso.
So Add one space or enter befor OPTIONAL then u will able to get results.
Hope this will work for this Query.