2

The following Wikidata query does not work as I would expect it:

# WikiData SPARQL Query
#
# Wolfgang Fahl 2018-01-06
#
# get father of queen victoria
SELECT ?queenVictoria ?queenVictoriaLabel ?fatherProperty ?fatherPropertyLabel ?father ?fatherLabel
WHERE {
#  
# father
# https://www.wikidata.org/wiki/Property:P42
# Queen Victoria
# https://www.wikidata.org/wiki/Q9439
  BIND (wdt:P22 AS ?fatherProperty).
  BIND (wd:Q9439 AS ?queenVictoria).
  ?queenVictoria ?fatherProperty ?father.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

try it!

The result is

queenVictoria queenVictoriaLabel fatherProperty fatherPropertyLabel                     father.      fatherLabel   
wd:Q9439      Queen Victoria     wdt:P22        http://www.wikidata.org/prop/direct/P22 wd:Q157009   Prince Edward Augustus, Duke of Kent and Strathearn

I was expecting the labels to be Queen Victoria, father and "Prince Edward Augustus".

Whats wrong with my query? Or is this a bug?

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186
  • 1
    As to "Queen Victoria", 9429 != 9439. As to "father", it seems that Wikidata label service supports `wd`-properties only. As to "Prince Edward", look into Wikidata page. – Stanislav Kralin Jan 19 '18 at 10:04
  • 1
    :D that is **not** Queen Victoria, click https://www.wikidata.org/wiki/Q9429 – UninformedUser Jan 19 '18 at 10:05
  • Correct output: `wd:Q9439 Victoria wdt:P22 http://www.wikidata.org/prop/direct/P22 wd:Q157009 Edward Augustus, Duke of Kent and Strathearn` – UninformedUser Jan 19 '18 at 10:06
  • @WolfgangFahl, [try it](https://query.wikidata.org/#SELECT%20%3FqueenLabel%20%3FrealpropertyLabel%20%3FfatherLabel%0AWHERE%20%7B%0A%20%20VALUES%20%28%3Fqueen%29%20%7B%28wd%3AQ9439%29%7D%0A%20%20VALUES%20%28%3Fproperty%29%20%7B%28wdt%3AP22%29%7D%0A%20%20%3Fqueen%20%3Fproperty%20%3Ffather%20.%0A%20%20%3Frealproperty%20wikibase%3AdirectClaim%20%3Fproperty%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22de%22.%20%7D%0A%7D). – Stanislav Kralin Jan 19 '18 at 10:16
  • @Stanislav Kralin - thank you - I fixed the typo - please post your comment as an answer and I'll accept it. – Wolfgang Fahl Jan 19 '18 at 10:39

1 Answers1

3

The reason why http://www.wikidata.org/prop/direct/P22 is returned instead of father is that Wikidata truthy predicates do not have labels (try DESCRIBE wdt:P22). Only proper properties have labels (try DESCRIBE wd:P22).

Wikidata label service could wrap this situation, but it doesn't:

SERVICE wikibase:label only supplies labels for entities in the wd: namepace.

Thus, try this query:

SELECT ?queenLabel ?realpropertyLabel ?fatherLabel
WHERE {
  VALUES (?queen) {(wd:Q9439)}
  VALUES (?property) {(wdt:P22)}
  ?queen ?property ?father .
  ?realproperty wikibase:directClaim ?property
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
} 
Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58