根据“三元组不存在”选择使用 sparql;
我需要一点帮助从我的商店中选择正确的三元组...
<a> a <type/1> .
<b> a <type/1> .
<c> a <type/1> .
<c> a <type/2> .
我只想选择 type/1 而不是 type/2 的元素
使用 sparql select 查询实现此目的的最佳方法是什么?
我正在寻找类似的东西:
select ?a where
{
?a a <type/1> .
!{ ?a a <type/2> }
}
谢谢,
:)
I need a little help selecting the right triples from my store....
<a> a <type/1> .
<b> a <type/1> .
<c> a <type/1> .
<c> a <type/2> .
i want to select only elements which are type/1 and not type/2
What is the best way to achieve this using a sparql select query?
am looking for omething like:
select ?a where
{
?a a <type/1> .
!{ ?a a <type/2> }
}
Thanks,
:)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
另一种 SPARQL 1.1 解决方案是使用
MINUS
,例如MINUS
从现有匹配中减去与其三重模式匹配的解决方案。在大多数情况下,使用
FILTER NOT EXISTS { }
和MINUS { }
是等效的,但要注意在某些极端情况下情况并非如此 - 请参阅 SPARQL 1.1 规范 了解一些示例。An alternative SPARQL 1.1 solution is to use
MINUS
e.g.MINUS
subtracts solutions that match its triple pattern from the existing matches.In most cases using
FILTER NOT EXISTS { }
andMINUS { }
are equivalent but beware there are some corner cases where this is not true - see the SPARQL 1.1 specification for some examples of this.在 SPARQL 1.0 中,这有点棘手:
OPTIONAL
子句为任何具有的
,并且对于任何没有它的?a
绑定?othertype
。?a
使其保持未绑定状态。然后,最终的FILTER 仅选择
?a
未绑定的那些行。在 SPARQL 1.1 中更容易:
In SPARQL 1.0 that's a bit tricky:
The
OPTIONAL
clause binds?othertype
for any?a
that has<type/2>
, and leaves it unbound for any?a
that doesn't have it.The final
FILTER
then selects only those rows where?a
was left unbound.In SPARQL 1.1 it's much easier: