Hi Hyrundo,

The query as written is executed locally, and when execution reaches the SERVICE clauses the engine calls out to the named service.

Instead of:
  QueryExecutionFactory.sparqlService
use
  QueryExecutionFactory.create

    Andy

On 27/11/2019 16:23, Hyrundo Publishing Association wrote:
Hello Sirs at Jena,

I am following the examples of federated queries given at this URL:
https://www.oclc.org/developer/news/2016/federated-queries-with-sparql.en.html 
<https://www.oclc.org/developer/news/2016/federated-queries-with-sparql.en.html>

and then I’m trying to replicate the results bringing those SPARQL examples 
into a Jena/Java Main class in NetBeans…
with no results…


For example, the given SPARQL code:

PREFIX schema: <http://schema.org/>
PREFIX library: <http://purl.org/library/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX dct: <http://purl.org/dc/terms/>
SELECT ?work ?workLabel
FROM <http://www.worldcat.org/oclc/470488115>
WHERE {
<http://www.worldcat.org/oclc/470488115> schema:author ?creatorURI.
BIND(replace(STR(?creatorURI), "^(.*[\\/])*", "") AS ?creatorID)
{SERVICE <https://query.wikidata.org/sparql> { //endpoint n.1
        ?author wdt:P214 ?creatorID.
        ?work wdt:P50 ?author .
   ?    work wdt:P1476 ?workLabel
   }
}
UNION
{
SERVICE <http://bnb.data.bl.uk/sparql> { //endpoint n.2
        ?bl_creator  ?creatorURI.
        ?work dct:creator ?bl_creator.
        ?work dct:title ?workLabel
        }
   }
}
When having two different endpoints to query, how to set the query execution in 
Jena?
Query query = QueryFactory.create(queryStr);
QueryExecution qexec = 
QueryExecutionFactory.sparqlService(“http://URL_of_the_SPARQL_endpoint";, query) 
  ?

Any hint?
Thank you in advance.



Hyrundo


Reply via email to