SPARQL DESCRIBE 查询 [英] SPARQL DESCRIBE query
问题描述
似乎我不理解 SPARQL DESCRIBE 查询.我需要检索与条件匹配的资源的完整图表.在我尝试过的一个 SPARQL 端点上(挪威 Rådata Nå,http://data.bibsys.no/data/query_authority.html) 这很好用:
Seems I don't grok SPARQL DESCRIBE queries. I need to retrieve the full graphs of resources matching a condition. On one SPARQL endpoint I have tried (Norwegian Rådata Nå, http://data.bibsys.no/data/query_authority.html) this works just fine:
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
DESCRIBE ?person WHERE {
?person rdf:type foaf:Person .
FILTER EXISTS { ?person owl:sameAs ?sameAs }
}
LIMIT 100
我得到了具有 owl:sameAs
三元组的 Person 资源的结果.
I get a result with Person resources that have an owl:sameAs
triple.
在其他 SPARQL 端点上,Onki Light (http://sparql.onki.fi/sparql.tpl) 和 DBPedia (http://dbpedia.org/sparql) 类似的查询
On other SPARQL endpoints, Onki Light (http://sparql.onki.fi/sparql.tpl) and DBPedia (http://dbpedia.org/sparql) a similar query
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
DESCRIBE ?x WHERE {
?x rdf:type skos:Concept .
FILTER EXISTS { ?x skos:prefLabel ?prefLabel }
}
LIMIT 100
返回大量既没有 rdf:Type = skos:Concept
也没有 skos:prefLabel
的资源,所以我显然没有正确执行查询.应该如何声明这种查询以产生我需要的结果?
returns lots of resources which have neither rdf:Type = skos:Concept
nor a skos:prefLabel
, so I am obviously not doing the query correctly. How should this kind of query be stated to produce the result I need?
推荐答案
收到的资源"没有 skos:prefLabel
或 skos:Concept
可能与满足您要求的资源相关.
The "received resources" without skos:prefLabel
or skos:Concept
are probably related to a resource that meets your requirements.
SPARQL DESCRIBE 查询实际上并不返回与该查询的图形模式匹配的资源,而是一个描述"该查询的 RDF 图.那些资源.由 sparql 服务选择包含哪些三元组来描述资源.(见下面的标准)
The SPARQL DESCRIBE query does not actually return resources matched by the graph pattern of the query, but an RDF graph that "describes" those resources. It is up to the sparql service to choose what triples are included to describe a resource. (see the standard below)
DESCRIBE 表单返回包含有关资源的 RDF 数据的单个结果 RDF 图.[...] 描述由查询服务决定.
The DESCRIBE form returns a single result RDF graph containing RDF data about resources. [...] The description is determined by the query service.
因此,您意外收到的资源可能描述了您真正想要的资源.要调查您的问题:检查您实际收到的三元组是否与您想要的有关资源.一个好方法是从 LIMIT 1
开始,看看 DESCRIBE 查询的效果.
So, the resources you unexpectedly receive maybe describing the resources you actually want. To investigate your issue: Check the triples you should actually receive for a relation to your wanted resource. A good way is to start with LIMIT 1
to see the effect of DESCRIBE queries.
也许您需要 SELECT 查询?它只返回与图模式匹配的资源.
Maybe a SELECT query is what you need? It returns only the resources matched by the graph pattern.
这篇关于SPARQL DESCRIBE 查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!