0

I would like to ask, how to do a federated SPARQL query on a subgraph of a SPARQL endpoint (not the entire remote SPARQL endpoint).

I got my data in Virtuoso v7 while the SPARQL endpoint is "http://localhost:8890/sparql", I'd like to do a remote query on a subgraph of this endpoint which is "http://localhost:8890/TC", and I tried

SELECT  *
WHERE
   { SERVICE <http://localhost:8890/sparql>
       { SELECT  ?subject ?predicate ?object
         FROM <http://localhost:8890/TC>
         WHERE
           { ?subject  ?predicate  ?object }
       }
   } LIMIT 50

And I got the error that "FROM" is not correctly used, so I have two questions:

1) can I do a remote query on a subgraph of a SPARQL endpoint?

2) can I have a SPARQL endpoint for each graph in Virtuoso v7?

Thanks a lot for your help.

Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58
  • 1
    1.) No, you can't - see the [grammar](https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#grammar) – UninformedUser Oct 30 '17 at 19:17
  • 1
    Add `?default-graph-uri=...` where `...` is the%-encoded URI to the SERVICE call. Try DBedpia's UI to see this in action. – AndyS Oct 30 '17 at 19:20

1 Answers1

0

You can use graph instead of from.

In your example:

SELECT  *
WHERE
{ 
  SERVICE <http://localhost:8890/sparql>
  { 
    SELECT  ?subject ?predicate ?object
    WHERE
     { graph <http://localhost:8890/TC> { ?subject  ?predicate  ?object } }
  }
} LIMIT 50

I tested this syntax with the following query in the Uniprot SPARQL endpoint (Virtuoso) while federating with dbpedia (Virtuoso):

SELECT  *
WHERE
   { SERVICE <http://dbpedia.org/sparql>
       {select distinct ?activity where { graph <http://dbpedia.org> {?activity a <http://www.ontologydesignpatterns.org/ont/d0.owl#Activity>} } LIMIT 10
       }
   } LIMIT 50
biogeek
  • 561
  • 1
  • 4
  • 13