0

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?

ChrisW
  • 4,970
  • 7
  • 55
  • 92
  • 1
    Your query is correct and should filter the resultset. So it's a bug in the D2RQ server then – UninformedUser Oct 05 '16 at 17:48
  • 4
    Also, if you're looking to do a case insensitive substring match, there's no reason to invoke all the power of regex. It's just `contains(lcase(?freetext), "liverpool")`. – Joshua Taylor Oct 05 '16 at 18:07

0 Answers0