You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SPARQL查询返回0结果求助:维基数据艺术运动查询及DBpedia同类问题

解决Wikidata/DBpedia SPARQL查询艺术运动无结果的问题

嘿,刚踏入查询语言和关联数据领域的话,遇到0结果确实容易懵,我来帮你捋清楚问题出在哪,再给你调整好的查询语句~

首先,你的原查询没写完,但大概率是没正确限定艺术运动的类别,或者用错了关联属性,导致SPARQL找不到匹配的数据。下面分别给你Wikidata和DBpedia的可用查询:

Wikidata 修正后的查询

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?art ?artLabel ?artist ?artistLabel ?startDate ?endDate ?country ?countryLabel
WHERE {
  # 限定主体是艺术运动(Wikidata中艺术运动的ID是Q15324)
  ?art wdt:P31 wd:Q15324.
  
  # 关联艺术家:这里包含创始人、知名成员两种常见关联
  { ?art wdt:P112 ?artist } UNION { ?art wdt:P1080 ?artist }.
  
  # 可选的起止日期和所属国家(用OPTIONAL避免过滤掉缺失这些数据的条目)
  OPTIONAL { ?art wdt:P580 ?startDate. }
  OPTIONAL { ?art wdt:P582 ?endDate. }
  OPTIONAL { ?art wdt:P17 ?country. }
  
  # 获取多语言标签(默认英文,可加LANGUAGE参数指定中文)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,zh". }
}
LIMIT 100

关键调整点:

  • 明确用wdt:P31 wd:Q15324限定查询对象是艺术运动,这是避免0结果的核心——原查询可能没做这个筛选,导致范围太宽或不对
  • 用UNION同时匹配创始人(P112)和知名成员(P1080),覆盖你要的“创始人/发明者/创作者、知名领域”关联
  • 用OPTIONAL包裹日期和国家字段,避免因为部分艺术运动缺失这些数据而被过滤掉
  • 加入标签服务,让返回结果显示可读的名称而非纯URI

DBpedia 修正后的查询

DBpedia的属性和类别命名和Wikidata不同,所以需要对应调整:

PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?art ?artLabel ?artist ?artistLabel ?startDate ?endDate ?country ?countryLabel
WHERE {
  # 限定主体是DBpedia的艺术运动类别
  ?art a dbo:ArtMovement.
  
  # 关联艺术家:创始人、知名人物
  { ?art dbo:founder ?artist } UNION { ?art dbo:notablePerson ?artist }.
  
  OPTIONAL { ?art dbo:startDate ?startDate. }
  OPTIONAL { ?art dbo:endDate ?endDate. }
  OPTIONAL { ?art dbo:country ?country. }
  
  # 获取标签
  ?art rdfs:label ?artLabel.
  ?artist rdfs:label ?artistLabel.
  OPTIONAL { ?country rdfs:label ?countryLabel. }
  FILTER(LANG(?artLabel) = "en" || LANG(?artLabel) = "zh")
}
LIMIT 100

注意:

DBpedia的中文数据相对Wikidata少一些,如果要优先中文结果,可以调整FILTER里的语言顺序。

如果还是没结果,可能是你查询的艺术运动本身在知识库中数据缺失,但上面的查询应该能返回大量常见艺术运动的结果啦~

内容的提问来源于stack exchange,提问作者Nga

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:44:54