我想知道如何在GraphDB上执行联合搜索。例如,要在GraphDB中插入下面的代码,我应该如何做?这个想法是将下面的内容添加到我本地的GraphDB中。
#Locations of air accidents in wikidata - https://query.wikidata.org/
SELECT ?label ?coord ?place
WHERE
{
?subj wdt:P31 wd:Q744913 .
?subj wdt:P625 ?coord .
?subj rdfs:label ?label
filter (lang(?label) = "en")
}发布于 2020-09-01 23:09:52
发布了@UninformedUser的评论作为更好的可读性的答案。
SPARQL1.1提供了描述为here的SERVICE特性。您可以使用它直接在GraphDB中对Wikidata执行联邦查询。
SELECT * WHERE {
SERVICE <https://query.wikidata.org/sparql> {
?subj wdt:P31 wd:Q744913 ;
wdt:P625 ?coord ;
rdfs:label ?label
FILTER (lang(?label) = "en")
}
}发布于 2020-09-18 15:49:58
要将数据插入到本地GraphDB中,请使用类似以下内容:
INSERT {
?subj wdt:P31 wd:Q744913 ;
wdt:P625 ?coord ;
rdfs:label ?label
} WHERE {
SERVICE <https://query.wikidata.org/sparql> {
?subj wdt:P31 wd:Q744913 ;
wdt:P625 ?coord ;
rdfs:label ?label
FILTER (lang(?label) = "en")
}
}然而,你可能想要解开坐标并使用一些更容易理解的本体,例如:
PREFIX wgs: <http://www.w3.org/2003/01/geo/wgs84_pos#> # see http://prefix.cc/wgs.sparql
INSERT {
?subj a :AirAccident;
wgs:lat ?lat; wgs:long ?long;
rdfs:label ?label
} WHERE {
SERVICE <https://query.wikidata.org/sparql> {
?subj wdt:P31 wd:Q744913 ;
p:P625/psv:P625 [wikibase:geoLatitude ?lat; wikibase:geoLongitude ?long];
rdfs:label ?label
FILTER (lang(?label) = "en")
}
}有关p:P625, psv:P625, wikibase:geoLatitude的内容,请参阅https://github.com/nichtich/wdq#wikidata-ontology (如果您安装了它,wdq help ontology会给出颜色编码)
https://stackoverflow.com/questions/63637449
复制相似问题