Why filter doesn't work in this context?

2019-07-14 04:52发布

问题:

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.

回答1:

?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)
}