Fetching wikidata properties from an entity discovered by property value

45 views Asked by At

I'm attempting to find location data by the url of an entity. This query returns zero results, but if I replace the P856 clause with ?item wdt:* wd:Q48340 . it works just fine.

SELECT ?item ?itemDescription ?locationLabel ?cityLabel ?postalCodeLabel ?countryLabel ?countryISOCodeLabel ?coordinates ?coordinatesLabel WHERE {
  ?item wdt:P856 "https://www.cnn.com/" .
  OPTIONAL {  }
  OPTIONAL { ?item wdt:P276 ?address. }
  OPTIONAL { ?item wdt:P159 ?headquarters. }
  BIND(COALESCE(?address, ?headquarters) AS ?location)
  OPTIONAL { ?location wdt:P131 ?city. }
  OPTIONAL { ?location wdt:P281 ?postalCode. }
  OPTIONAL { ?location wdt:P17 ?country. }
  OPTIONAL { ?country wdt:P297 ?countryISOCode. }
  OPTIONAL { ?location wdt:P625 ?coordinates. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
1

There are 1 answers

0
Stefan - brox IT-Solutions On BEST ANSWER

For the entity CNN (Q48340), the wdt:P856 value is an IRI, not a string.

?item wdt:P856 <https://www.cnn.com/> .