我遇到Federated Query
的问题。它仅用作我的项目的示例。
我通过维基数据库中的DBpedia SPARQL端点检索所有维基媒体类别,但不问题,因为下面的查询在维基数据中有效。
但是当我想在Apache Jena Query上运行它时,它会抛出一个HttpException 404
。的为什么吗
查询:
prefix bd: <http://www.bigdata.com/rdf#>
prefix dbc: <http://dbpedia.org/resource/Category:>
prefix dct: <http://purl.org/dc/terms/>
prefix wikibase: <http://wikiba.se/ontology#>
SELECT ?objectLabel WHERE {
SERVICE <http://dbpedia.org/sparql> {
?subject dct:subject dbc:Countries_in_Asia ; owl:sameAs ?object
FILTER (STRSTARTS(STR(?object), "http://www.wikidata.org"))
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
Java代码:
public static ResultSet executeQuery(String queryString, String service) {
Query query = QueryFactory.create(queryString);
QueryEngineHTTP queryEngine = QueryExecutionFactory.createServiceRequest(service, query);
ResultSet resultSet = queryEngine.execSelect();
return resultSet;
}
Service =我使用https://query.wikidata.org/sparql
Apache Jena中的异常跟踪:
HttpException: 404
at org.apache.jena.sparql.engine.http.HttpQuery.execGet(HttpQuery.java:325)
at org.apache.jena.sparql.engine.http.HttpQuery.exec(HttpQuery.java:282)
at org.apache.jena.sparql.engine.http.QueryEngineHTTP.execResultSetInner(QueryEngineHTTP.java:342)
at org.apache.jena.sparql.engine.http.QueryEngineHTTP.execSelect(QueryEngineHTTP.java:334)
答案 0 :(得分:2)
远程服务器返回404。 wikibase:label不是真正的SPARQL端点。如果通过SERVICE远程调用在本地执行,则不能在SERVICE子句中使用它。