首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >聚合查询会导致Blazegraph而不是Sesame上的错误

聚合查询会导致Blazegraph而不是Sesame上的错误
EN

Stack Overflow用户
提问于 2017-03-18 01:26:36
回答 2查看 363关注 0票数 2

我只是在将一个应用程序从Sesame迁移到Blazegraph,下面的查询有一个问题。它在芝麻上正常工作,但是Blazegraph报告了一个错误:

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

透光仪的错误是:

代码语言:javascript
复制
java.util.concurrent.ExecutionException: org.openrdf.query.MalformedQueryException: Bad aggregate

这是一个Ubuntu安装的Blazegraph:

代码语言:javascript
复制
Build Version=2.0.0  
Build Git Commit=516e5a7014af1fbe378772c02d51ba1046f53e08

我怎样才能解决这个问题?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-03-28 06:35:36

根据SPARQL 1.1规范

在聚合查询和子查询中,出现在查询模式中但不在GROUP BY子句中的变量只有在聚合的情况下才能投影或在select表达式中使用。

可能是,Sesame实现扩展了SPARQL 1.1规范,允许投影子句中的变量,这些变量在group by中没有提到。

但是,通常需要在select和group子句中指定所有变量:

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

或者使用样本聚合:

代码语言:javascript
复制
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
票数 2
EN

Stack Overflow用户

发布于 2017-03-18 23:51:16

我可以在白热片上重现这个错误。这显然是group by的一个问题。它与以下方面合作:

代码语言:javascript
复制
group by ?name ?otherperson
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42869427

复制
相关文章

相似问题

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