Jump to: navigation, search


The SPARQLStore is the name for the component that can establish a connection between a RDF triple store and Semantic MediaWiki (a more general introduction can be found [here]( SPARQL and RDF stores)).

The SPARQLStore is composed of a base store (by default using the existing SQLStore), a QueryEngine, and a connector to the RDF back-end. Currently, the base store takes the position of accumulating information about properties, value annotations, and statistics.



Repository connector

A repository connector is responsible for establishing a communication between Semantic MediaWiki and an external TDB with the main objective to transfer/update triples from SMW to the back-end and to return result matches for a query request.

The following client repositories have been tested:

Create a connection

$connectionManager = new ConnectionManager();

    new RepositoryConnectionProvider( 'fuseki' )

$connection = $connectionManager->getConnection( 'sparql' )


The QueryEngine is responsible for transforming an #ask description object into a qualified SPARQL query expression.

  • The CompoundConditionBuilder builds a SPARQL condition from an #ask query artefact (aka Description object)
  • The condition is transformed into a qualified SPARQL statement for which the repository connector is making a http request to the back-end while awaiting an expected list of subjects that matched the condition in form of a XML or JSON response
  • The raw results are being parsed by a HttpResponseParser to provide a unified RepositoryResult object
  • During the final step, the QueryResultFactory converts the RepositoryResult into a SMW specific QueryResult object which will fetch the remaining data (those selected as printrequests) from the base store and make them available to a QueryResultPrinter

Create a query request

 * Equivalent to [[Foo::+]]
 * ?result swivt:wikiPageSortKey ?resultsk .
 * ?result property:Foo ?v1 .
 * }
 * ORDER BY ASC(?resultsk)
$description = new SomeProperty(
    new DIProperty( 'Foo' ),
    new ThingDescription()

$query = new Query( $description );

$sparqlStoreFactory = new SPARQLStoreFactory(
  new SPARQLStore()

$queryEngine = $sparqlStoreFactory->newMasterQueryEngine();
$queryResult = $queryEngine->getQueryResult( $query );