简单的sparql查询不起作用,日期比较

时间:2012-02-07 12:52:23

标签: sparql dbpedia

我在dbpedia sparql端点上得到“SR171:Transaction timed out”,用于以下简单查询:为什么我会收到此错误?我没有设置任何超时 - 它是0。

PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX : <http://dbpedia.org/resource/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
PREFIX dbpedia: <http://dbpedia.org/>

PREFIX ont: <http://dbpedia.org/ontology/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?date (bif:substring(STR(?date), 1, 4) AS ?year) WHERE {
   ?person ont:birthDate ?date .
   ?person foaf:name ?name   

   . FILTER ( (fn:string-length(STR(?date)) = 10) && (bif:substring(STR(?date), 9, 2) = '05') && (bif:substring(STR(?date), 6, 2) = '02') && (?date > "1868-01-01"^^xsd:date) && (?date < "2005-01-01"^^xsd:date) )

1 个答案:

答案 0 :(得分:7)

这是因为您的查询对于DBPedia端点来说太难以回答而不会对服务的其他用户产生负面影响。

由于DBPedia是众所周知的公共SPARQL端点,因此它被大量使用,因此托管它的人员将其配置为严格限制查询可以运行的时间,以便恶意用户不会使服务无法使用其他

在您的情况下,您的查询将花费很长时间,因为您会询问具有大量初始结果的内容(准确地说是592299),然后对其应用FILTERFILTER在SPARQL中非常昂贵,特别是在进行字符串操作和日期比较时。 AFAIK DBPedia超时是相当低的几秒钟,并且端点无法在该时间内完成查询,因为应用FILTER需要很长时间。

注意 - 这是我用来查看查询的第一部分返回了多少结果的查询:

PREFIX ont: <http://dbpedia.org/ontology/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT COUNT(*) 
WHERE 
{
   ?person ont:birthDate ?date .
   ?person foaf:name ?name   
}
相关问题