SPARQL-Query for all objects with a specific prefix?

1.7k Views Asked by At

I created an ontology with different prefixes (rdf, rdfs, owl, example, car, bike, ...). I use them to demarcate different domains and examples.

How can I query for all objects with the profix i.e. "car"?

Thank you in advance!

1

There are 1 best solutions below

1
On BEST ANSWER

For the future, providing a minimal sample of the data will help in providing a working query on the data. With no further detailsand assuming that you mean by "objects" the objects of triples (and indeed untested) :

PREFIX car: <TODO_ADD_URI_OF_NAMESPACE_HERE>
SELECT * {
 ?s ?p ?o .
 FILTER(isUri(?o) && STRSTARTS(STR(?o), STR(car:)))
}