Kuzeko
Kuzeko

Reputation: 1705

SPARQL Return only IRIs/URIs as result

In SPARQL how do I retrieve only IRIs (or URIs) as a result of a BGP?

E.g. in

SELECT ?s ?o WHERE 
    {?s ?p ?o }
LIMIT 100

Return only those ?o that are IRIs

Upvotes: 1

Views: 327

Answers (1)

Kuzeko
Kuzeko

Reputation: 1705

In SPARQL there exist the following tests

SPARQL tests: isIRI, isURI, isBlank, isLiteral, isNumeric, bound

isIRI, isURI: returns true if the term is an IRI or a URI

isBlank: returns true if the term is a blank node

isLiteral: returns true if the term is a literal

isNumeric: returns true if the term is a numeric value

Source:List of SPARQL Filter Functions (Dataworld tutorial)

Hence you can write

SELECT ?s ?o WHERE {
       ?s ?p ?o 
       FILTER(isIRI(?o)) 
} limit 100

Upvotes: 2

Related Questions