本文介绍了组图模式在SPARQL中如何工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我不知道这是否真的称为组图模式.无论如何,

First of all, i don't know if this really called group graph pattern or not. Anyway,

请查看此查询

select ?x  ?y where {
  {?x rdf:type rs:Recommendable}
 union
  {?xd rs:doesntexist ?y}
} 

没有 rs:doesntexist,但使用union时,我仅从第一个子图{?x rdf:type rs:Recommendable}

there is no rs:doesntexist but with union i got the results only from the first sub graph which is {?x rdf:type rs:Recommendable}

但是如果我删除工会,那么查询将是:

but if i remove the union, so the query will be:

select ?x  ?y where {
  {?x rdf:type rs:Recommendable}

  {?xd rs:doesntexist ?y}
}

我得到的结果是空的,请问这是谁的作品?

I get empty results, may I ask you please who this work?

和这个查询对我来说很奇怪

and the weird thing to me that this query

select ?x  ?y where {
  {?x rdf:type rs:Recommendable}.{}

}

可以完美地工作,所以之前的那个不起作用吗?

works perfectly so the one before it doesnt?

我不确定工会是可选的,我不确定.请问对吗? (并且是可选的,我并不是说来自sparql的可选,但是我的意思是像从一个联合中提取数据时,两个图,两个图都有数据,但是如果其中一个为空,我们将得到数据从另一个)

I think the union is like optional, I'm not sure. is it right please? (and by optional i didn't mean the optional from sparql, but i meant like when extracting the data from a union two graphs, its optional that two of them have data but if one of them is empty, we'll have the data from the other)

推荐答案

select ?x  ?y where {
  {?x rdf:type rs:Recommendable}

  {?xd rs:doesntexist ?y}
}

类似于(不完全相同):

is like (not identical) to:

select ?x  ?y where {
  ?x rdf:type rs:Recommendable
  ?x rs:doesntexist ?y
}

两个模式必须匹配.如果没有rs:doesntexist,则整个操作都会失败.

Both patterns must match. If there is no rs:doesntexist the whole thing fails.

{}

匹配所有(零个)模式,因此它始终有效.

matches all (zero) its patterns so it always works.

这篇关于组图模式在SPARQL中如何工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 16:26