Lukas Walcher
Lukas Walcher

Reputation: 29

Wikidata SPARQL query is missing part of expected results

On Wikidatas SPARQL endpoint i tried to find all cities worldwide with a population greater than 100000. I'm getting lots of correct results with my query. But when i checked for some particular cities they didn't show up in the list.

My query:

  SELECT DISTINCT ?cityLabel ?population ?coord ?countryLabel ?shortCountry ?city  WHERE {
  ?city (wdt:P31/(wdt:P279*)) wd:Q515;
    wdt:P1082 ?population;
    wdt:P625 ?coord.
  FILTER(?population > 100000 )
  ?city wdt:P17 ?country.
  ?country wdt:P298 ?shortCountry.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY ASC (?shortCountry)

I looked for the following cities in the results:

But they didn't show up.

Try it out here

Upvotes: 1

Views: 118

Answers (1)

Lukas Walcher
Lukas Walcher

Reputation: 29

Ok i figured something out for myself:

I dug a little deeper into the wikidata object of the cities i mentioned and found out, that they are no instance of "city" (Q515).

Berlin belongs to e.g. "capital", "city with millions of inhabitants", "metropolis"

Lyon belongs to "commune of france" and "big city"

Beirut belongs to e.g. "capital" and "big city"

But none of them is listed as a "city". That's for sure not intentionally because other bigger cities are also an instance of "city" e.g. Paris

So in conclusion:

Check all the categories your filtering for and check your expected results to match them.

Upvotes: 1

Related Questions