How to filter the simple Subject in a SPARQL Query

1.6k views Asked by At

I guess I am stuck at the basics with SPARQL. Can someone help ?

I simply wnat to filter all subjects containing "Mountain" of an RDS database.

Prefix lgdr:<http://linkedgeodata.org/triplify/> Prefix lgdo:<http://linkedgeodata.org/ontology/> 
Select * where { 
?s ?p ?o . 
filter (contains(?s, "Mountain"))
} Limit 1000

The query leads to an error:

Virtuoso 22023 Error SL001: The SPARQL 1.1 function CONTAINS() needs a string value as first argument
1

There are 1 answers

0
Cleb On BEST ANSWER

You can get it to "work" using:

Prefix lgdr:<http://linkedgeodata.org/triplify/> Prefix lgdo:<http://linkedgeodata.org/ontology/> 
Select * where { 
?s ?p ?o . 
filter (contains(str(?s), "Mountain"))
} Limit 1000

Note the additional str in the query.

However, that results in

Virtuoso S1T00 Error SR171: Transaction timed out

and I am not sure how to deal with that.

But in principle in works: When you use

Limit 1

you get

s   p   o
http://linkedgeodata.org/ontology/MountainRescue    http://www.w3.org/1999/02/22-rdf-syntax-ns#type     http://www.w3.org/2002/07/owl#Class