问题描述
这是查询和结果:
如您所见,我正在过滤掉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)
}
这篇关于为什么过滤器在这种情况下不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!