I have been given what I thought would be a simple task - take an existing SPARQL query and adapt the WHERE clause to restrict results to entities where a specific text field contains a specific search term.
However, I am entirely new to the SPARQL language and nothing I've tried is working. It seems I need to use the text:query (rdfs:label 'word' 10)
syntax, but I haven't managed to successfully integrate this into the query below.
What I need is to further filter the results of the below query where the rdfs:label triple has a value containing the search term. If any of you could provide guidance about how I need to change the query I'd be very grateful.
SELECT DISTINCT * WHERE
{
{ SELECT ?object ?label ?accessionNumber ?image WHERE {
?object a my:Object .
?object my:accessionNumber ?accessionNumber .
?object rdfs:label ?label .
?object my:maker <http://id.my.org.uk/agent/1234> .
}}
OPTIONAL {
?object my:preferredAsset ?asset .
?asset a my:Asset .
?asset dcterms:hasVersion ?image .
?image my:role 'thumbnail' .
}
}
Thanks in advance.
regex
, though. You can just dofilter contains( lcase(?label), "word")
. That may be a bit cheaper, since the matching is simpler. – Bagehot