R3000
(R3000)
March 13, 2019, 5:32pm
1
The following query returns 1423 triples:
SELECT *
{
?s ?p ?o .
filter(?p = skos:broader)
}
After successfully running this DELETE query:
DELETE WHERE
{
?s skos:broader ?o .
}
I ran again the SELECT query and getting back the same 1423 triples.
Any idea why?
Do I need to commit after delete?
Thanks,
Radu
dlbis
(Daniel Lavoie)
March 13, 2019, 5:42pm
2
Hi Radu,
In the following example, I am using a different syntax that works fine to delete all triples related to a given resource type.
with graph_iri
delete
{?s ?p ?o}
where {
?s rdf:type onto:resourceType .
?s ?p ?o }
I believe you should do:
delete
{?s ?p ?o}
where {
values(?p) {(skos:broader)}
?s ?p ?o }
R3000
(R3000)
March 13, 2019, 5:49pm
3
Dan,
Thanks for trying to help me.
No errors running what you recommended but select still shows all 1423 broaders
Regards,
Radu
stephen
(stephen)
March 14, 2019, 12:08pm
4
Hi Radu,
I can't seem to reproduce your issue. Do you have an example minimal data set where you reliably see this behavior? What version of Stardog are you using?
R3000
(R3000)
March 14, 2019, 1:12pm
5
Here is the content of the exported trig file. Once you create a stardog db you will need to add arch type - skos= and also check query all graphs. TIA.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix skosxl: <http://www.w3.org/2008/05/skos-xl#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix tags: <http://www.holygoat.co.uk/owl/redwood/0.1/tags/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix cycAnnot: <http://sw.cyc.com/CycAnnotations_v1#> .
@prefix csw: <http://semantic-web.at/ontologies/csw.owl#> .
@prefix dbpedia: <http://dbpedia.org/resource/> .
@prefix freebase: <http://rdf.freebase.com/ns/> .
@prefix opencyc: <http://sw.opencyc.org/concept/> .
@prefix cyc: <http://sw.cyc.com/concept/> .
@prefix ctag: <http://commontag.org/ns#> .
<https://example.com/Test/thesaurus> {<https://example.com/Test/3> skos:prefLabel "Four"@en;
dcterms:created "2019-01-02T16:29:28.395Z"^^xsd:dateTime .
<https://example.com/Test/0> dcterms:title "One"@en;
dcterms:created "2019-01-02T16:28:58.029Z"^^xsd:dateTime;
a skos:ConceptScheme;
rdfs:label "One"@en;
dcterms:creator <https://example.com/user/user2> .
<https://example.com/Test/1> dcterms:created "2019-01-02T16:29:09.540Z"^^xsd:dateTime;
dcterms:creator <https://example.com/user/user2>;
skos:topConceptOf <https://example.com/Test/0>;
skos:prefLabel "Two"@en .
<https://example.com/Test/0> skos:hasTopConcept <https://example.com/Test/1> .
<https://example.com/Test/1> a skos:Concept .
<https://example.com/Test/2> skos:broader <https://example.com/Test/1>;
dcterms:created "2019-01-02T16:29:19.358Z"^^xsd:dateTime;
a skos:Concept;
skos:prefLabel "Three"@en .
<https://example.com/Test/1> skos:narrower <https://example.com/Test/2> .
<https://example.com/Test/2> dcterms:creator <https://example.com/user/user2> .
<https://example.com/Test/3> skos:broader <https://example.com/Test/2>;
a skos:Concept .
<https://example.com/Test/2> skos:narrower <https://example.com/Test/3> .
<https://example.com/Test/3> dcterms:creator <https://example.com/user/user2> .
}
stephen
(stephen)
March 14, 2019, 1:13pm
6
Radu,
Since you have query.all.graphs=true
your SELECT query would return data in any number of named graphs, however your DELETE query would still need to specify the named graph in order to delete the data.
If you want it gone from all graphs you can run the following:
DELETE WHERE {
graph <tag:stardog:api:context:all> {
?s skos:broader ?o .
}
}
R3000
(R3000)
March 14, 2019, 1:23pm
7
Stephen,
What you are saying it makes sense. However after issuing the above delete - I am still getting two rows after select
BTW - I had also to add an entry into Namespaces:
skos=http://www.w3.org/2004/02/skos/core#
Thanks for trying to help,
Radu
stephen
(stephen)
March 14, 2019, 2:37pm
8
If you run SELECT * { graph ?g {?s skos:broader ?o} }
, do you get a graph name bound in those 2 rows?
It might be a little overkill, but the following should clobber all of the triples:
DELETE {?s skos:broader ?o} WHERE {?s skos:broader ?o};
DELETE {GRAPH ?g {?s skos:broader ?o} } WHERE { GRAPH ?g {?s skos:broader ?o} }
R3000
(R3000)
March 14, 2019, 3:14pm
9
Yes the select above returned 2 rows.
And yes this time the two triples are gone. Thank you.
I don't know why we need two delete statements though ... but could it be because skos:narrower is part of a symmetric relation - and not allowing a one delete statement to do its job? ... a mystery for now.
Thanks again,
Radu
matthias
(Matthias Autrata)
March 14, 2019, 3:35pm
10
The Sparql spec does not specify what the “default graph” actually is.
“Depending on implementation, the unnamed graph may refer
to a separate graph, a graph describing the named graphs, a representation of a union of other graphs, etc.”
So, you cannot assume that a Delete operation on the default graph will also delete triples from other named graphs.
1 Like
matthias
(Matthias Autrata)
March 14, 2019, 3:43pm
11
Also, see here Home | Stardog Documentation Latest and specifically the query.all.graphs option.
1 Like
system
(system)
Closed
March 28, 2019, 3:43pm
12
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.