mu-cl-resources
mu-cl-resources copied to clipboard
:or: filter does not work in combination with :uri: filter
When using the :or:
filter and one of them is a :uri:
filter, the created query internally will not be correct.
e.g. for filter[:or:][:uri:]=test&filter[:or:][:exact:alias]=test
the query is:
SELECT DISTINCT ?uuid WHERE {
GRAPH <http://mu.semte.ch/application> {
?s mu:uuid ?uuid; a ?class. VALUES ?class {void:Dataset}.
{
VALUES ?s { <test> }
} UNION
{
?s ext:alias """test""".
} } } GROUP BY ?uuid OFFSET 0 LIMIT 20
This problem arises from using the VALUES
block:
https://www.w3.org/TR/sparql11-query/#inline-data
VALUES provides inline data as a solution sequence which are combined with the results of query evaluation by a join operation.
A potential solution that works as expected would be
PREFIX mu: <http://mu.semte.ch/vocabularies/core/>
PREFIX ext: <http://mu.semte.ch/vocabularies/ext/>
PREFIX void: <http://rdfs.org/ns/void#>
SELECT DISTINCT ?uuid WHERE {
GRAPH <http://mu.semte.ch/application> {
?s mu:uuid ?uuid; a ?class. VALUES ?class {void:Dataset}.
{
{ SELECT ?s WHERE { VALUES ?s { <test> } } }
} UNION {
?s ext:alias """test""".
}
}
} GROUP BY ?uuid OFFSET 0 LIMIT 20
or using a FILTER
instead of VALUES
(but this would be slower).