performance - 在 SPARQL 屏蔽结果中排序
问题描述
我在 Sparql 中有一个很长的查询,我想按数字字段“sentiment”对结果进行排序,如果我在 SELECT 和 GROUPBY 中包含该字段,一切正常,否则会崩溃。但是我想呈现查询而不像在 SQL 查询中那样显示“情绪”字段。这在 SPARQL 中可行吗?
查询是:
SELECT ?Sentiment ?Restaurant ?Name ?Address ?Score ?City ?State (SAMPLE(?photo) as ?image) SAMPLE(?Text) as ?text) (SAMPLE(?Review) as ?review) (SAMPLE(?TStyle) as ?style) (SAMPLE(?TAmbiance) as ?ambient) (SAMPLE(?TService) as ?service)
where { ?Restaurant :hasName ?Name;
:Dish ?Dish;
:Score ?Score;
:hasAddress ?Address;
:photo ?photo;
:HasReview ?Review;
:Parking ?Parking;
:CreditCard ?CreditCard;
:Delivery ?Delivery;
:Kids ?Kids;
:hasTopic ?o;
:Sentiment ?Sentiment.
?Address :hasCity ?City;
:hasState ?State;
:Lat ?Lat;
:Long ?Long.
?Review :Text ?Text.
BIND (exists{?Restaurant :hasTopic :style} AS ?TStyle).
BIND (exists{?Restaurant :hasTopic :ambiance} AS ?TAmbiance).
BIND (exists{?Restaurant :hasTopic :service} AS ?TService).
FILTER(contains(str(?Text), "sushi"))
} GROUP BY ?Restaurant ?Name ?Address ?Score ?City ?State ?Sentiment
ORDER BY DESC((?Sentiment))
如何在不显示“情绪”字段本身或总体上改进查询的情况下形成查询并对结果进行排序?
谢谢。
解决方案
感谢您的报告。如果未投影变量,则 ORDER BY 问题可能会出错,这是一个已知的 AllegroGraph 问题 (bug25806),将在即将发布的 7.0 版本中修复。
推荐阅读
- zurb-foundation - 如何在基础 6 中使用 readmore.js
- java - TestNG 断言似乎不适用于 Cucumber / Gherkin Doc Strings?
- django - 如何只允许特定国家的用户访问我的 django 网站?
- javascript - 如何检查我的对象是否存在于 javascript 地图中?
- c# - ILMerge 抛出 System.OutOfMemoryException
- javascript - 找不到名称“firebase”.ts(2304)
- java - 使用本机查询的 JPA 查询返回 null 而不是实体列表
- javascript - 是什么让每个嵌入的对象 contentDocument 都“独一无二”,即使有两个(或更多)同一个对象源的实例?
- java - 使用并行流执行基于条件的加法
- ios - Swift 中小数位的 NumberFormatter