【发布时间】:2018-03-22 02:08:45
【问题描述】:
我想检索具有相同类型(类)的实例的所有不同对象属性,从两个初始种子(wd:Q963 和 wd:Q42320)开始。首先,我询问此类种子的类型(可能还有子类型)。其次,检索同一类种子的所有实例。第三,检索实例的属性。最后,我想检索这些属性的描述以及可能的替代标签。我的查询如下:
select distinct ?property ?description ?label where{
{
wd:Q963 wdt:P31 ?typesSubject .
?instancesS (wdt:P31|wdt:P279) ?typesSubject .
?instancesS ?property ?unknown .
}
UNION
{
wd:Q42320 wdt:P31 ?typesObject .
?instancesO (wdt:P31|wdt:P279) ?typesObject .
?unknown ?property ?instancesO .
}
?claimPredicate wikibase:directClaim ?property .
?claimPredicate schema:description ?description .
?claimPredicate rdfs:label ?label .
FILTER(strstarts(str(?property),str(wdt:)))
FILTER(strstarts(str(?unknown),str(wd:)))
FILTER(LANG(?description) = "en").
FILTER(LANG(?label) = "en").
}
问题是我的实际查询需要很长时间,并且在公共 Wikidata 端点中失败。有谁可以给我一些提示来优化这样的查询?
【问题讨论】:
-
407属性的检索大约需要 3 秒:select distinct ?property where{ { ?instancesS (wdt:P31|wdt:P279)/^wdt:P31 wd:Q963 . ?instancesS ?property ?unknown . FILTER(strstarts(str(?property),str(wdt:))) } UNION { ?instancesO (wdt:P31|wdt:P279)/^wdt:P31 wd:Q42320 . ?unknown ?property ?instancesO . FILTER(strstarts(str(?unknown),str(wd:))) } }问题在于声明的加入 -
谢谢@AKSW,你是对的,我不知道如何解决这样的加入问题
标签: properties query-optimization sparql union wikidata