首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GraphDB -联邦查询

GraphDB -联邦查询
EN

Stack Overflow用户
提问于 2020-08-29 00:13:04
回答 2查看 217关注 0票数 0

我想知道如何在GraphDB上执行联合搜索。例如,要在GraphDB中插入下面的代码,我应该如何做?这个想法是将下面的内容添加到我本地的GraphDB中。

代码语言:javascript
复制
#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")
}
EN

回答 2

Stack Overflow用户

发布于 2020-09-01 23:09:52

发布了@UninformedUser的评论作为更好的可读性的答案。

SPARQL1.1提供了描述为hereSERVICE特性。您可以使用它直接在GraphDB中对Wikidata执行联邦查询。

代码语言:javascript
复制
SELECT * WHERE {
    SERVICE <https://query.wikidata.org/sparql> {
        ?subj wdt:P31 wd:Q744913 ;
            wdt:P625 ?coord ;
            rdfs:label ?label
        FILTER (lang(?label) = "en")
    }
}
票数 1
EN

Stack Overflow用户

发布于 2020-09-18 15:49:58

要将数据插入到本地GraphDB中,请使用类似以下内容:

代码语言:javascript
复制
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")
    }
}

然而,你可能想要解开坐标并使用一些更容易理解的本体,例如:

代码语言:javascript
复制
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会给出颜色编码)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63637449

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档