Federated Queries and Federation#

Corese facilitates Federated Queries, enabling users to execute SPARQL queries seamlessly across multiple data sources or endpoints. This document guides you through utilizing Federated Queries and Federation in Corese and details the configuration necessary.

  1. Federated Queries and Federation

    1. 1. Federated Queries

    2. 2. Federations

1. Federated Queries#

Basic syntax:

Use the @federate directive to specify different endpoints. Below is the basic syntax:

@federate <uri1endpoint1> <uri2endpoint2> 
select * where {?x ?p ?y}

Retrieving Provenance Information:

To obtain additional details on the origin of the data, include the @provenance keyword:

@federate <uri1endpoint1> <uri2endpoint2> 
@provenance
select * where {?x ?p ?y}

Configuration for Corese-Server:

In Corese-Server, it’s necessary to explicitly specify the list of allowed endpoints. For more details, refer to Restrict Access to External Endpoints.

For non-public servers, the -su option can be used to allow all endpoints:

java -jar corese-server.jar -su

This option executes the server in superuser mode, allowing connections to all endpoints. This setting is not recommended for public servers due to security concerns.

2. Federations#

A Federation in Corese is a named set of endpoints, defined in a file to avoid the repetition of listing endpoints in each query.

Defining a Federation:

  1. Create a federation.ttl file with the following content:

# Define a federation
<http://myserver.fr/myname/federate> a st:Federation ;
    st:definition (
        <endpoint1> 
        <endpoint2>
    ).
  1. Next, create a config.properties file with the following line

FEDERATION = /path/to/federation.ttl
  1. Launch Corese using the config.properties file:

java -jar corese-server.jar -init config.properties
java -jar corese-gui.jar -init config.properties
echo "" | java -jar corese-command.jar sparql -if turtle -q ./query.rq --init config.properties

Note: echo "" and -if turtle are workaround methods as this command is not designed to function without input.

  1. Finally, execute a federated query using the federation:

@federation <http://myserver.fr/myname/federate>
select * where {?x ?p ?y}