我只是在将一个应用程序从Sesame迁移到Blazegraph,下面的查询有一个问题。它在芝麻上正常工作,但是Blazegraph报告了一个错误:
PREFIX schema: <http://schema.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?otherperson ?name (count(?name) as ?count) WHERE {
?article schema:mentions <http://trove.alveo.edu.au/name/8e0fd54e145f0d0643fec64731d488fa> .
?article schema:mentions ?otherperson .
?article dcterms:title ?articletitle .
?otherperson foaf:name ?name .
filter (<http://trove.alveo.edu.au/name/8e0fd54e145f0d0643fec64731d488fa> != ?otherperson)
} group by ?name
order by desc(?count)
LIMIT 50透光仪的错误是:
java.util.concurrent.ExecutionException: org.openrdf.query.MalformedQueryException: Bad aggregate这是一个Ubuntu安装的Blazegraph:
Build Version=2.0.0
Build Git Commit=516e5a7014af1fbe378772c02d51ba1046f53e08我怎样才能解决这个问题?
发布于 2017-03-28 06:35:36
在聚合查询和子查询中,出现在查询模式中但不在GROUP BY子句中的变量只有在聚合的情况下才能投影或在select表达式中使用。
可能是,Sesame实现扩展了SPARQL 1.1规范,允许投影子句中的变量,这些变量在group by中没有提到。
但是,通常需要在select和group子句中指定所有变量:
PREFIX schema: <http://schema.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?otherperson ?name (count(?name) as ?count) WHERE {
?article schema:mentions <http://trove.alveo.edu.au/name/8e0fd54e145f0d0643fec64731d488fa> .
?article schema:mentions ?otherperson .
?article dcterms:title ?articletitle .
?otherperson foaf:name ?name .
filter (<http://trove.alveo.edu.au/name/8e0fd54e145f0d0643fec64731d488fa> != ?otherperson)
}
group by ?otherperson ?name
order by desc(?count)
LIMIT 50或者使用样本聚合:
PREFIX schema: <http://schema.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT (sample(?otherperson) as ?otherperson) ?name (count(?name) as ?count) WHERE {
?article schema:mentions <http://trove.alveo.edu.au/name/8e0fd54e145f0d0643fec64731d488fa> .
?article schema:mentions ?otherperson .
?article dcterms:title ?articletitle .
?otherperson foaf:name ?name .
filter (<http://trove.alveo.edu.au/name/8e0fd54e145f0d0643fec64731d488fa> != ?otherperson)
}
group by ?name
order by desc(?count)
LIMIT 50发布于 2017-03-18 23:51:16
我可以在白热片上重现这个错误。这显然是group by的一个问题。它与以下方面合作:
group by ?name ?otherpersonhttps://stackoverflow.com/questions/42869427
复制相似问题