Using union in a struct sparql query

I have a graph rdfwith several entries. Now I want to get all the associated troins with the given identifier. This is my sparql request:

select ?s ?p ?o from <http://localhost:8890/DAV/ranking> where {
 {<http://seekda.com/providers/cdyne.com/PhoneNotify> so:hasEndpoint ?s.
 ?s ?p ?o} union
 {<http://seekda.com/providers/cdyne.com/PhoneNotify> ?p ?o}
}

The identifier in this case <seekda.com/providers/cdyne.com/PhoneNotify>.

But I need a graph request ( constructor describe). So I think I need to pack them togheter with union. How to do it?

+3
source share
1 answer

Short answer: there is no difference.

Longer answer: Think of SPARQL queries as having two parts.

  • The part of the query (WHERE) that creates the list of variable bindings (although some variables may be unbound).

  • , . SELECT, ASK, CONSTRUCT DESCRIBE.

SELECT * . SELECT ?v1 ?v2 . ASK , - .

CONSTRUCT , RDF . . , .

DESCRIBE , node, . , , .

, UNION, OPTIONAL, , . - .

. {?s ?p ?o}. ? , .

:

construct { <http://seekda.com/providers/cdyne.com/PhoneNotify> ?p ?o }
from <http://localhost:8890/DAV/ranking> 
where {
  { <http://seekda.com/providers/cdyne.com/PhoneNotify> so:hasEndpoint ?s.
    ?s ?p ?o }
  union
  { <http://seekda.com/providers/cdyne.com/PhoneNotify> ?p ?o }
}
+2

Source: https://habr.com/ru/post/1743323/


All Articles