SPARQL 类型转换?
我有以下 SPARQL 查询:
PREFIX ssn: <http://purl.oclc.org/NET/ssnx/ssn#>
PREFIX dtp: <http://dtp-126.sncs.abdn.ac.uk#>
PREFIX dbp: <http://dbpedia.org/resource/>
SELECT ?value ?time WHERE {
dtp:CD7514 ssn:madeObservation ?observation .
?observation ssn:observedProperty ?property .
?property ssn:hasValue <http://dbpedia.org/resource/Temperature> .
?observation ssn:observationResult ?observationValue .
?observationValue ssn:hasValue ?value .
?observationValue ssn:observationSamplingTime ?time
FILTER(?time > 1291908000)
}
简而言之,它是从传感器 dtp:CD7514 选择所有温度传感器观测值,并过滤掉小于给定时间戳的值。
但是,添加过滤器约束会返回 0 个结果(当存在与该时间区域匹配的观测值时!)
是否有可能 ?time 是 varchar/text/String 数据类型,因此无法进行比较?如果是这样,是否可以在 SPARQL 中进行转换?
I have the following SPARQL query:
PREFIX ssn: <http://purl.oclc.org/NET/ssnx/ssn#>
PREFIX dtp: <http://dtp-126.sncs.abdn.ac.uk#>
PREFIX dbp: <http://dbpedia.org/resource/>
SELECT ?value ?time WHERE {
dtp:CD7514 ssn:madeObservation ?observation .
?observation ssn:observedProperty ?property .
?property ssn:hasValue <http://dbpedia.org/resource/Temperature> .
?observation ssn:observationResult ?observationValue .
?observationValue ssn:hasValue ?value .
?observationValue ssn:observationSamplingTime ?time
FILTER(?time > 1291908000)
}
Which, in a nutshell, is selecting all temperature sensor observations from a sensor, dtp:CD7514, and filtering out values less than the given timestamp.
However, adding the filter constraint returns 0 results (when there are observations that match this time region!)
Is it possible that ?time is a varchar/text/String data type and therefore the comparison can't be done? If so, is it possible to do the conversion within SPARQL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仅当您匹配的时间值具有相同的位数时,这才有效,因为它将进行强比较。更好的解决方法是:
将 ?time 中的值转换为整数,然后对其进行数字比较。
That's only going to work if the time value you're matching has the same number of digits, as it will do a strong compare. A better fix would be:
That will cast the value in ?time to an integer, and then do a numeric compare on it.
解决方案只是在时间戳周围添加引号。
The solution to this was merely to add quotes around the timestamp.