I want to retrieve Indian districts, states, and cities. I have the following query which I think should do that (I’m omitting the prefixes).
CONSTRUCT {?state rdfs:label ?stateLabel ;
dbo:country dbr:India ;
geo:lat ?latitude ;
geo:long ?longitude ;
dbo:populationTotal ?population;
dbo:abstract ?abs.
?city rdf:type dbo:City ;
rdfs:label ?cityLabel ;
dbo:isPartOf ?state;
dbo:abstract ?abs.}
WHERE {{?state rdf:type dbo:State ;
rdfs:label ?stateLabel ;
dbo:country dbr:India ;
geo:lat ?latitude ;
geo:long ?longitude ;
dbo:populationTotal ?population;
dbo:abstract ?abs.
FILTER (lang(?stateLabel) = "en" && lang(?abs) = "en")}
UNION
{?state rdf:type dbo:AdministrativeRegion ;
rdfs:label ?stateLabel ;
dbo:country dbr:India ;
geo:lat ?latitude ;
geo:long ?longitude ;
dbo:populationTotal ?population;
dbo:abstract ?abs .
FILTER (lang(?stateLabel) = "en" && lang(?abs) = "en")}
OPTIONAL {?city rdf:type dbo:City ;
rdfs:label ?cityLabel ;
dbo:isPartOf ?state;
dbo:abstract ?abs.
FILTER (lang(?cityLabel) = "en" && lang(?abs) = "en")}}
ORDER BY ?stateLabel
This returns the districts but it doesn’t return any cities or states. I’ve tried smaller parts of this query where I just query for the states or cities and it doesn’t return anything.