1

I try to write a simple SPARQL query using WDQS to show some information about a city. My first attempt was to filter using a check for equality, like:

SELECT ?city ?cityLabel
WHERE 
{
  ?city wdt:P31/wdt:P279* wd:Q515 .
  FILTER(?city = wd:Q8471) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

However, this query returns no records. My next attempt was to use "IN":

FILTER (?city in (wd:Q8471)) .

The result is the same as above. Then I found a solution using "VALUES":

SELECT ?city ?cityLabel
WHERE 
{
  ?city wdt:P31/wdt:P279* wd:Q515 .
  VALUES ?city
  {
    wd:Q8471
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

This solution works and returns 2 records. But it's not clear to me, why a simple "=" comparision as in "FILTER(?city = wd:Q8471)" does not work in this query (I successfully used it in another query). Funnily enough I found out that enhancing the comparision with "?city = wd:0" (either "FILTER(?city = wd:0 || ?city = wd:Q8471)" or "FILTER (?city in (wd:Q8471, wd:Q0))") leads to the result I expected.

What is the error in my considerations?

3
  • This bug is due to the label service (there exist proper Blazegraph bugs though). Comment out SERVICE etc. Jan 3 at 17:24
  • @StanislavKralin Thanks for the explanation. If I comment out SERVICE, I don't have that feature available any more, but of course, I need it. Is there any real solution despite my workaround? Jan 4 at 16:53
  • w.wiki/tCh Jan 4 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.