>> :tdbGraph1 rdf:type tdb2:GraphTDB2 ;
>> tdb2:dataset :tdbDataset .
>>
>> :tdbGraph2 rdf:type tdb2:GraphTDB2 ;
>> tdb2:dataset :tdbDataset .
Those are the same base graph for the inference engine (the default
graph - left over from using tdb2:unionDefaultGraph?).
Is that what you intended or did you want to have different base graphs
in which case you need "tdb2:graphName" with the appropriate names.
:tdbGraph1 rdf:type tdb2:GraphTDB2 ;
tdb2:dataset :tdbDataset ;
tdb2:graphName <http://example/aGraph> .
:tdbGraph2 rdf:type tdb2:GraphTDB2 ;
tdb2:dataset :tdbDataset ;
tdb2:graphName <http://example/OtherGraph> .
Andy
On 11/11/2020 15:55, abdullah ibrahim wrote:
Hello everyone,
i was facing a problem in supporting inference for all named graphs within
the same dataset, my up-to-now fix is creating inference mode per named
graph, but that raise a new problem which:
the inference is working for named graphs but when query named graphs seem
that both shared the same data, even if i ingest different data on each
graph.
what i have done in more details:
*1. config.ttl*
PREFIX : <#>
PREFIX fuseki: <http://jena.apache.org/fuseki#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ja: <http://jena.hpl.hp.com/2005/11/Assembler#>
PREFIX tdb2: <http://jena.apache.org/2016/tdb#>
[] rdf:type fuseki:Server ;
fuseki:services (
:service
) .
# Service description for "/dataset" with all endpoints.
:service rdf:type fuseki:Service ;
fuseki:name "dataset" ;
fuseki:endpoint [
fuseki:operation fuseki:query ;
fuseki:name "query"
] ;
fuseki:endpoint [
fuseki:operation fuseki:update ;
fuseki:name "update"
] ;
fuseki:dataset :dataset ;
.
## ---------------------------------------------------------------
:dataset rdf:type ja:RDFDataset ;
#ja:defaultGraph :model_inf ;
ja:namedGraph [
ja:graphName <http://www.example.com/ontology> ;
ja:graph :model_ontology ;
] ;
ja:namedGraph [
ja:graphName <http://www.example.com/hello> ;
ja:graph :model_inf
] ;
ja:namedGraph [
ja:graphName <http://www.example.com/world> ;
ja:graph :model_inf
] ;
.
:model_ontology a ja:InfModel ;
ja:baseModel :tdbGraph1 ;
#Reference to model.ttl file
ja:content [ja:externalContent "model.ttl" ] ;
#Enable Jena Rules-based reasoner and we point the location of
myrules.rules file
ja:reasoner [
ja:reasonerURL <
http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
ja:rulesFrom <file:////myrules.rules> ] ;
.
:model_inf a ja:InfModel ;
ja:baseModel :tdbGraph2 ;
#Reference to model.ttl file
#ja:content [ja:externalContent "model.ttl" ] ;
#Enable Jena Rules-based reasoner and we point the location of
myrules.rules file
ja:reasoner [
ja:reasonerURL <
http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
ja:rulesFrom <file:////myrules.rules> ] ;
.
:tdbGraph1 rdf:type tdb2:GraphTDB2 ;
tdb2:dataset :tdbDataset .
:tdbGraph2 rdf:type tdb2:GraphTDB2 ;
tdb2:dataset :tdbDataset .
## Base data in TDB.
:tdbDataset rdf:type tdb2:DatasetTDB2 ;
tdb2:location "DB" ;
# If the unionDefaultGraph is used, then the "update" service should
be removed.
#tdb2:unionDefaultGraph true ;
.
2. *Ingest data into hello graph:*
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX hello: <http://www.example.com/hello>
PREFIX world: <http://www.example.com/world>
PREFIX ns: <http://www.example.org/ns#>
INSERT DATA
{
GRAPH hello: {
ns:P1 rdf:type ns:Man.
ns:P2 rdf:type ns:Man.
ns:P1 ns:knows ns:P2.
}
}
3. *Ingest data into world graph:*
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX hello: <http://www.example.com/hello>
PREFIX world: <http://www.example.com/world>
PREFIX ns: <http://www.example.org/ns#>
INSERT DATA
{
GRAPH world: {
ns:P3 rdf:type ns:Man.
ns:P4 rdf:type ns:Man.
ns:P3 ns:knows ns:P4.
}
}
4. *Query*
SELECT *
WHERE
{
GRAPH hello: {
?s ?p ?o.
}
}
The results are combinations of all data from hello graph + world graph +
model graph, and the same if i do the query for world graph too.
Why are the graphs combined?, how can i fix that while keeping the
inference in separate per graph making each named graph use the ontology
model independent from other named graphs.
Thanks