I have a graph of Person
s stored in a StarDog instance, and a graph of Address
es in a Fuseki instance. One of the Person
instances has a hasAddress
relationship with an Address
.
I wish to make a SPARQL query that simply returns all the Person
s who have an address, as well as the address at which they live. This query is going to sent to the StarDog instance (the endpoint with the Person
graph). The query I am using is
prefix testOnt: <http://www.example.org/test-ontology#>
SELECT ?person ?address
WHERE {
?person testOnt:hasAddress ?address
}
However, this returns no results.
I am initialising the StarDog database using this bit of TTL:
:SomeDude rdf:type owl:NamedIndividual , :Person;
:hasAddress :Address1.
Where Address1
is defined in the TDB on the Fuseki side.
I just don't know how I'm meant to reference the second graph when I make a query to the other.
Thanks for any help, and I can clarify any points in the comments.
Your query to retrieve just ?person testOnt:hasAddress ?address
should work against Stardog but would not return address information stored in Fuseki. If this query is not working then make sure the namespaces you use in the data and the query match.
In order to get people instances from Stardog and their addresses from Fuseki you will need a federated SPARQL query that uses the SERVICE
keyword. Assuming namespaces are correct, your query should look like this:
prefix testOnt: <http://www.example.org/test-ontology#>
SELECT ?person ?address
WHERE {
?person testOnt:hasAddress ?address
SERVICE <http://fuseki/location> {
?address ?p ?o # use a more specific BGP here if necessary
}
}