How do I create a query that just returns asserted individuals, not blank nodes (anonymous individuals) if they exist?
Here is my SPARQL query:
PREFIX ont: <http://ontologies/aa-CurrentOntology#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT DISTINCT ?ind
WHERE {
?ind rdf:type ont:Size .
}
ORDER by ?ind
Here are some of the results (solutions):
sol: ( ?ind = <http://ontologies/aa-CurrentOntology#Big> )
sol: ( ?ind = <http://ontologies/aa-CurrentOntology#Small> )
sol: ( ?ind = _:b0 )
sol: ( ?ind = _:b1 )
sol: ( ?ind = _:b2 )
sol: ( ?ind = _:b3 )… thousands more after this
I want the query to only return the first two results, not the last four (_:b0, _:b1, etc). These do not exist in my input OWL file. I realize the blank nodes are probably because of the way the ontology is defined, but is there a way to eliminate them from the query result set?
I tried adding:
FILTER isURI (?ind)
...but this still requires all blank nodes to be calculated before being filtered out. Unfortunately, there seem to be thousands of blank nodes and the query never completes.
Is there a way of stating
don't bother calculating blank nodes
?