为什么过滤器在这种情况下不起作用? [英] Why filter doesn't work in this context?

查看:101
本文介绍了为什么过滤器在这种情况下不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是查询和结果:

如您所见,我正在过滤掉bo:ania的用户,为什么它们仍然出现?

但是,如果我删除宽卡并仅选择用户?user,则不会出现bo:ania

我没有提供最低限度的数据示例,因为这是关于过滤器和通配符如何工作的问题,而不是关于从数据集中提取某些数据的问题.但是,如果您需要最少的数据,我很乐意提供.

解决方案

?specificUser通过VALUES语句绑定到bo:ania. ?user是由其他三元模式定义的完全不同的绑定.您的FILTER说要在?user = bo:ania处过滤掉结果,并且看来?user在任何结果中都没有绑定到bo:ania,这似乎是正确的做法.

顺便说一句,除非您要检查多个值,否则在这种情况下无需使用VALUES.如果只是一个值,那么下面的方法将起作用,并且您不知道为什么对bo:ania的绑定包含在结果集中:

SELECT *
WHERE {
  ?user a rs:user .
  ?user rs:hasRated ?rating .
  ?rating rs:hasRatingDate ?ratngDate .
  FILTER (?ratingDates >= (now() -"P10000F"^^xsd:duration) )
  FILTER (?user != bo:ania)
}

This is the query and the result:

As you see, I am filtering out the users that are bo:ania, so why do they still appear?

However, if I remove the widecard and select just the users ?user, bo:ania doesn't appear

I didn't provide a minimum data example because this is a question about how filter and wildcard work, not about a problem in extracting some data from a data set. However, if you need a minimum data, I'm more than happy to provide it.

解决方案

?specificUser is bound to bo:ania by your VALUES statement. ?user is an entirely different binding defined by the other triple patterns. Your FILTER says to filter out results where ?user = bo:ania, and it appears to be doing that correctly, seeing that ?user is not bound to bo:ania in any of the results.

BTW, there isn't a need to use VALUES in this case unless you want to inspect multiple values. If it's just the one value, then the following would work, and not have you wondering why the binding to bo:ania is included in the result set:

SELECT *
WHERE {
  ?user a rs:user .
  ?user rs:hasRated ?rating .
  ?rating rs:hasRatingDate ?ratngDate .
  FILTER (?ratingDates >= (now() -"P10000F"^^xsd:duration) )
  FILTER (?user != bo:ania)
}

这篇关于为什么过滤器在这种情况下不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆