Internal SPARQL federation

In addition to the standard SPARQL 1.1 Federation to other SPARQL endpoints, GraphDB supports internal federation to other repositories in the same GraphDB instance. The internal SPARQL federation is used in almost the same way as the standard SPARQL federation over HTTP, and has several advantages:

Speed
The HTTP transport layer is bypassed and iterators are accessed directly. The speed is comparable to accessing data in the same repository.
Security
When security is ON, you can access every repository that is readable by the currently authenticated user. Standard SPARQL 1.1 federation does not support authentication.
Flexibility
Inline parameters provide control over inference and statement expansion over owl:sameAs.

Usage

Instead of providing a URL to a remote repository, you need to provide a special URL of the form repository:NNN, where NNN is the ID of the repository you want to access. For example, to access the repository authors via internal federation use a query like this:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX books: <http://example.com/books/>

SELECT ?authorName WHERE {
    ?book rdfs:label "The Hitchhiker's Guide to the Galaxy" ;
        books:author ?author .

    SERVICE <repository:authors> {
        ?author rdfs:label ?authorName
    }
}

Parameters

There are two parameters that control how the federated part of the query is executed:

infer (boolean)

Controls if inferred statements are included. True by default.

When this value is set to false, it is equivalent to adding FROM <http://www.ontotext.com/explicit> to the federated query.

sameAs (boolean)

Controls if statements are expanded over owl:sameAs. True by default.

When this value is set to false, it is equivalent to adding FROM <http://www.ontotext.com/disable-sameAs> to the federated query.

To set a parameter put a comma after the special URL referring to the internal repository, then the parameter name, an equals sign and finally the value of the parameter. If you need to set more than one parameter put another comma, parameter name, equals sign and value.

Some examples:

repository:NNN,infer=false
Turns off inference and inferred statements are not included in the results.
repository:NNN,sameAs=false
Turns off the expansion of statements over owl:sameAs and they are not included in the results.
repository:NNN,infer=false,sameAs=false

Turns off the inferred statements and they are not included in the results.

Turns off the expansion of statements over owl:sameAs and they are not included in the results.

Note

This needs to be a valid URL and thus there cannot be spaces/blanks.

The example SPARQL query from above will look like this if you want to skip the inferred statements and disable the expansion over owl:sameAs:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX books: <http://example.com/books/>

SELECT ?authorName WHERE {
    ?book rdfs:label "The Hitchhiker's Guide to the Galaxy" ;
        books:author ?author .

    SERVICE <repository:authors,infer=false,sameAs=false> {
        ?author rdfs:label ?authorName
    }
}