问题描述
下面的查询是我的问题accepted answer的Getting only english property value。当在Wikidata查询服务try it!上使用时,它将显示诸如澳大利亚-> AUS和奥地利-> AUT等国家的简称。在基于Apache Jena Fuseki的my local Wikidata copy created a few weeks ago上运行相同的查询,shortName列保持为空(请参见下面的屏幕截图)。
造成这种差异的原因是什么,如何将查询修改为也可以与Apache Jena Fuseki一起使用?
# get a list countries with the corresponding ISO code
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
SELECT ?country ?countryLabel ?shortName (MAX(?pop) as ?population) ?coord ?isocode
WHERE
{
# instance of country
?country wdt:P31 wd:Q3624078.
OPTIONAL {
?country rdfs:label ?countryLabel filter (lang(?countryLabel) = "en").
}
OPTIONAL {
?country p:P1813 ?shortNameStmt. # get the short name statement
?shortNameStmt ps:P1813 ?shortName # the the short name value from the statement
filter (lang(?shortName) = "en") # filter for English short names only
filter not exists {?shortNameStmt pq:P31 wd:Q28840786} # ignore flags (aka emojis)
}
OPTIONAL {
# get the population
# https://www.wikidata.org/wiki/Property:P1082
?country wdt:P1082 ?pop.
}
# get the iso countryCode
{ ?country wdt:P297 ?isocode }.
# get the coordinate
OPTIONAL { ?country wdt:P625 ?coord }.
}
GROUP BY ?country ?countryLabel ?shortName ?population ?coord ?isocode
ORDER BY ?countryLabel
解决方法
@UninformedUser的测试查询:
.Show
在基于事实的wikidata导入上进行最新全部导入时,未给出结果。完整查询也是如此。还是要知道为什么查询不适用于真实数据集。