Search code examples
sparqlgraphdb

Querying data from DPBEDIA Using SPARQL and Service in GraphDB


I am using the free version of GraphDB and want to select some data from DBpedia.

The following is what I tried:

PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>

Select ?about 
WHERE {
    dbr:Eiffel_Tower a ?o .
    SERVICE <https://dbpedia.org/sparql> {
        dbr:Eiffel_Tower dbo:abstract ?about .
     }
    FILTER (LANG(?about) = "de")
}

However, I get no results.

If I run the query on http://factforge.net/ like:

Select ?about
Where {
    dbr:Eiffel_Tower dbo:abstract ?about .
}

or even like:

Select ?about 
WHERE {
    dbr:Eiffel_Tower a ?stuff .
    SERVICE <https://dbpedia.org/sparql> {
        dbr:Eiffel_Tower dbo:abstract ?about .
     }
    FILTER (LANG(?about) = "de")
}

I get what I want (I get 9 times the Germany about. Well, actually not quite, I want it only once.why?).

So my question is, why isn't it working and how can I make it work?

Thanks for help.


Solution

  • What DBpedia-linked data (i.e., anything describing dbr:Eiffel_Tower) have you loaded into your local GraphDB instance? I'm betting on "none."

    I think if you comment (or remove) the dbr:Eiffel_Tower a ?o . line, you'll get results.

    You should also move the FILTER into the subquery, because right now you're pulling much more data from DBpedia than you need or want.

    PREFIX dbo: <http://dbpedia.org/ontology/>
    PREFIX dbr: <http://dbpedia.org/resource/>
    
    SELECT ?about 
    WHERE
      {
      #  dbr:Eiffel_Tower a ?o .
         SERVICE <https://dbpedia.org/sparql>
           {
             dbr:Eiffel_Tower dbo:abstract ?about .
             FILTER (LANG(?about) = "de")
           }
      }