Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dealing with reading/writing to named graphs and the default graph in GraphDB #73

Open
mathib opened this issue Apr 24, 2020 · 3 comments

Comments

@mathib
Copy link

mathib commented Apr 24, 2020

Expected Behavior

By correctly setting the server.js config, I hope to query and write only to the default graph of my GraphDB instance.

Actual Behavior

In the server.js config, I first set the graphName to 'default', but this will also make LD-R retrieve triples from named graphs. When writing triples, they end up in the default graph. This is probably the expected behavior of GraphDB (also see this issue). To query the default graph only, I can write queries using the special named graph http://www.openrdf.org/schema/sesame#nil to limit the query to the default graph.

PREFIX sesame: <http://www.openrdf.org/schema/sesame#>
SELECT *
FROM sesame:nil
WHERE { ?s ?p ?o }

However, when I change in the server.js config the value of graphName to 'http://www.openrdf.org/schema/sesame#nil', I don't see any results appearing in LD-R. When making a new resource in LD-R, it is added to the named graph http://www.openrdf.org/schema/sesame#nil. If I try the same query again directly on GraphDB, I don't see the new resource. Only when I specifically query the named graph itself, I can find it:

PREFIX sesame: <http://www.openrdf.org/schema/sesame#>
SELECT *
WHERE { GRAPH sesame:nil { ?s ?p ?o } }

I don't know which queries are send by LD-R, but I guess the read and write queries use GRAPH, similar as in the last query. Is it possible to make an exception for GraphDB if graphName equals 'http://www.openrdf.org/schema/sesame#nil'? The read queries should be similar as the first query and the write queries should become something like:

INSERT DATA { inst:subj inst:pred inst:obj }

(no named graph in write queries, because it should go in the default graph instead of the 'virtual' named graph http://www.openrdf.org/schema/sesame#nil)

Steps to Reproduce the Problem

Use configs in 'static' mode and run GraphDB locally

Specifications

  • Version: LD-R 1.3.7
  • Platform: Windows 10
  • triplestore: GraphDB v8.6.1
@ali1k
Copy link
Owner

ali1k commented Apr 24, 2020

Can you check https://github.com/ali1k/ld-r/blob/master/services/utils/helpers.js#L170 to see how read/write behavior for GraphDB is defined?

@mathib
Copy link
Author

mathib commented Apr 24, 2020

graphName: 'default'

Read query:

SELECT DISTINCT ?s  ?title   WHERE {
	{
		SELECT DISTINCT ?s WHERE {
			?s rdf:type ?type . FILTER (?type IN (<https://w3id.org/bot#Site>,<https://w3id.org/bot#Building>,<https://w3id.org/bot#Storey>,<https://w3id.org/bot#Space>,<https://w3id.org/bot#Element>))
		}
		LIMIT 30 OFFSET 0
	}
	OPTIONAL { ?s rdfs:label ?title . }
}

update query:

INSERT DATA {
	 <https://mytest.org/nodeA> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/1587740182> .
}

graphName: 'http://www.openrdf.org/schema/sesame#nil'

read query:

SELECT (count(DISTINCT ?s) AS ?total) WHERE {
	GRAPH <http://www.openrdf.org/schema/sesame#nil> {
		 ?s rdf:type ?type . FILTER (?type IN (<https://w3id.org/bot#Site>,<https://w3id.org/bot#Building>,<https://w3id.org/bot#Storey>,<https://w3id.org/bot#Space>,<https://w3id.org/bot#Element>))
	 }
}

update query:

INSERT DATA {
	GRAPH <http://www.openrdf.org/schema/sesame#nil> {
		<http://ld-r.org/n1587731670> <http://www.w3.org/2000/01/rdf-schema#label> """exampleValue1587740397""" .
	}
}

@mathib
Copy link
Author

mathib commented Apr 29, 2020

hmm, I'm exploring GraphDBs way of dealing with NGs and it's pretty confusing at times. A short summary of the behaviour:

  • when querying the default graph you'll find all explicit and implicit triples from all the named graphs and the default graph
  • when querying a named graph using GRAPH <namedgraph>, you'll only find the explicit triples inside that named graph
  • when querying using FROM sesame:nil, only the explicit triples in the default graph are found

My current idea is to add another property for the server.js config besides graphName but for writing: writeGraphName. While graphName would be obligatory, it normally sets the read and write graph during querying using GRAPH <namedgraph> except when default is entered (this is the current situation). If however writeGraphName exists, LD-R should write to the named graph mentioned here using GRAPH <namedgraph> or the default graph in case of default. LD-R still continues to read from the named or default graph as set in graphName.

In case sesame:nil is detected for graphName, the read query should change GRAPH sesame:nil into FROM sesame:nil. The write query should then go to the default graph or if writeGraphName is set, to the named graph set here.

@mathib mathib changed the title GraphDB read/write to default graph fails dealing with reading/writing to named graphs and the default graph in GraphDB Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants