I've got a dataset (exposed via D2RQ) from which I can run the following SPARQL query
SELECT ?index ?freetext ?label WHERE
{
?s a prov:Agent ;
skos:notation ?index.
?s skos:description ?freetext .
OPTIONAL { ?s skos:prefLabel ?label }
}
and get a sensible result back:
index freetext label
--------------------------
1 "Some text containing Manchester" "Lancashire"
2 "Some text containing Liverpool" -
3 "Some text containing Manchester and Liverpool" "The North"
4 "Some text containing London" -
So far so good... now, I want to return the rows mentioning Liverpool:
SELECT ?index ?freetext ?label WHERE
{
?s a prov:Agent ;
skos:notation ?index.
?s skos:description ?freetext .
OPTIONAL { ?s skos:prefLabel ?label }
FILTER (regex(str(?freetext), "Liverpool", "i"))
}
which I want to return
index freetext label
--------------------------
2 "Some text containing Liverpool" -
3 "Some text containing Manchester and Liverpool" "The North"
but this returns all 4 rows again - i.e. the filtering is having no effect. I have tried every combination of FILTER EXISTS
, FILTER NOT EXISTS
, MINUS
, subquerying, etc I can think of, but to no avail.
Is what I'm trying to do possibe?