Difference between one SPARQL (working) query and another one (not working)

若如初见. 提交于 2020-01-06 08:16:05

问题


I want to get the scorers (marcatori) from this page: http://it.dbpedia.org/resource/Modena_Football_Club_1962-1963 using this SPARQL endpoint: http://uriburner.com/sparql/

If I use this query:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT
  ?team
  ?club
  (group_concat(distinct ?scorer;separator=";;;") as ?scorers) 
WHERE {
SERVICE <http://it.dbpedia.org/sparql/> {
   ?value rdfs:label "Campionato italiano di calcio Serie A"@it .
   ?year <http://purl.org/dc/terms/subject> ?value . 
   ?team <http://dbpedia.org/ontology/league> ?year .
   ?team <http://it.dbpedia.org/property/club> ?club .
   OPTIONAL { ?team <http://it.dbpedia.org/property/marcatori> ?scorer 
   }
}

} 
GROUP BY ?team ?club 
ORDER BY ?club
LIMIT 1 

I get no results, where as if I use this one:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT
  ?team
  ?club
WHERE {
SERVICE <http://it.dbpedia.org/sparql/> {
   ?value rdfs:label "Campionato italiano di calcio Serie A"@it .
   ?year <http://purl.org/dc/terms/subject> ?value . 
   ?team <http://dbpedia.org/ontology/league> ?year .
   ?team <http://it.dbpedia.org/property/club> ?club 
}

} 
GROUP BY ?team ?club 
ORDER BY ?club
LIMIT 1 

I correctly get:

{ "head": { "link": [], "vars": ["team", "club"] },
  "results": { "distinct": false, "ordered": true, "bindings": [
    { "team": { "type": "uri", "value": 
 "http://it.dbpedia.org/resource/Modena_Football_Club_1962-1963" }  , 
 "club": { "type": "uri", "value": 
 "http://it.dbpedia.org/resource/Modena_Football_Club" }} ] } }

Does anyone know why the first query returns empty?


回答1:


You can replace

(group_concat(distinct ?scorer;separator=";;;") as ?scorers)

with

sql:group_concat(?scorer, ";;;") as ?scorers

This should work fine on http://it.dbpedia.org/sparql, not sure why you need URI burner.



来源:https://stackoverflow.com/questions/53499065/difference-between-one-sparql-working-query-and-another-one-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!