wolfgang
wolfgang

Reputation: 7809

Why is this sparql query not returning any rows on dbpedia?

This is my query below, querying the country names with a certain minimum population, executing on http://dbpedia.org/sparql.

even though i change the population variable to a tiny amount. there are no rows being returned. why?

PREFIX type: <http://dbpedia.org/class/yago/>
PREFIX prop: <http://dbpedia.org/property/>
SELECT ?country_name ?population
WHERE {
    ?country a type:LandlockedCountries ;
             rdfs:label ?country_name ;
             prop:populationEstimate ?population .
    FILTER (?population > 15000000 && langMatches(lang(?country_name), "en")) .
} ORDER BY DESC(?population)

Upvotes: 0

Views: 92

Answers (1)

UninformedUser
UninformedUser

Reputation: 8465

Because there is no class http://dbpedia.org/class/yago/LandlockedCountries in DBpedia - I don't know why you think that there is such a class?

There is a Wikipedia category Landlocked_countries, thus, the URI would be http://dbpedia.org/resource/Category:Landlocked_countries and the property that relates resources to a category is http://purl.org/dc/terms/subject:

PREFIX prop: <http://dbpedia.org/property/>
PREFIX dbc: <http://dbpedia.org/resource/Category:>
PREFIX dct: <http://purl.org/dc/terms/>
SELECT *
WHERE {
    ?country dct:subject dbc:Landlocked_countries ;
    rdfs:label ?country_name ;
    prop:populationEstimate ?population .
    FILTER (?population > 15000000 && langMatches(lang(?country_name), "en")) .
} ORDER BY DESC(?population)

In general, "debugging" a SPARQL query can be done by starting with just a single triple pattern and checking if this returns the expected resp. any result.

Upvotes: 3

Related Questions