SPARQL联合查询未返回所有解决方案 [英] SPARQL Federated Query Not Returning All Solutions

查看:140
本文介绍了SPARQL联合查询未返回所有解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是这个问题

基本上,我很难从远程端点获取SPARQL查询的所有解决方案。我已经阅读了第2.4节此处,因为它似乎描述了情况几乎与我的情况相同。

Basically I am having trouble getting all the solutions to a SPARQL query from a remote endpoint. I have read through section 2.4 here because it seems to describe a situation almost identical to mine.

我的想法是我想根据本地RDF图中的信息从DBPedia中过滤出我的结果。查询在这里:

The idea is that I want to filter my results from DBPedia based on information in my local RDF graph. The query is here:

PREFIX ns1:             
<http://www.semanticweb.org/caeleanb/ontologies/twittermap#>
PREFIX dbo: <http://dbpedia.org/ontology/>

SELECT *
WHERE {
  ?p ns1:displayName ?name .
  SERVICE <http://dbpedia.org/sparql> {
    ?s rdfs:label ?name .
    ?s rdf:type foaf:Person .
  }
}

我得到的唯一结果是dbpedia:John_McCain(为?s)。我认为这是因为约翰·麦凯恩(John McCain)是前一个 x结果中唯一的匹配项,但我不知道如何获取查询以返回所有匹配项。例如,如果我添加一个过滤器,例如:

And the only result I get is dbpedia:John_McCain (for ?s). I think this is because John McCain is the only match in the first 'x' results, but I can't figure out how to get the query to return all matches. For example, if I add a filter like:

SERVICE <http://dbpedia.org/sparql> {
  ?s rdfs:label ?name .
  ?s rdf:type foaf:Person .
  FILTER(?name = "John McCain"@en || ?name = "Jamie Oliver"@en)
}

然后正确返回dbpedia:Jamie_Oliver和dbpedia:John_McCain。除非我专门将其添加到像这样的过滤器中,否则还有数十种其他匹配项不会通过,例如Jamie Oliver。

Then it correctly returns BOTH dbpedia:Jamie_Oliver and dbpedia:John_McCain. There are dozens of other matches like Jamie Oliver that do not come through unless I specifically add it to a Filter like this.

有人可以解释一种提取其余部分的方法吗比赛?谢谢。

Can someone explain a way to extract the rest of the matches? Thanks.

推荐答案

该问题的原因似乎是SERVICE块试图从DBPedia中提取所有泡沫:人员,然后根据我的本地Stardog数据库进行过滤。由于查询DBPedia时结果限制为10,000,因此只能找到在该10,000个任意Persons集合中发生的匹配项。为了解决这个问题,我编写了一个脚本,将一个包含了Stardog db中每个字符串名称的FILTER块放在一起,并将其附加到SERVICE块以进行远程过滤,从而避免达到10,000个结果限制。看起来像这样:

It looks like the cause of this issue is that the SERVICE block is attempting to pull all foaf:Persons from DBPedia, and then filter them based on my local Stardog db. Since there is a 10,000 result limit when querying DBPedia, only matches which occur in that set of 10,000 arbitrary Persons will be found. To fix this, I wrote a script to put together a FILTER block containing every string name in my Stardog db and attached it to the SERVICE block to filter remotely and thereby avoid hitting the 10,000 result limit. It looks something like this:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX ns1: <http://www.semanticweb.org/caeleanb/ontologies/twittermap#>

CONSTRUCT{
  ?s rdf:type ns1:Person ;
    ns1:Politician .
}
WHERE {
    ?s rdfs:label ?name .
    ?s rdf:type dbo:Politician .
    FILTER(?name IN ("John McCain"@en, ...)
}

这篇关于SPARQL联合查询未返回所有解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆