How to suppress objectProperty in Fuseki? - sparql

I've problem to suppress one objectProperty in graph on my fuseki server.
I tried to use many way to delete my objectProperty without results.
I tried to use s-delete to suppress:
./s-delete http://localhost:3030/ds 'DELETE {?s <http://www.semanticweb.org/ds/dependsOfExchange> ?o}'
or
./s-delete http://localhost:3030/ds 'DELETE {GRAPH ?g {?s <http://www.semanticweb.org/ds/dependsOfExchange> ?o} WHERE{?s <http://www.semanticweb.org/ds/dependsOfExchange> ?o}}'
I tried to find some information about how to use correctly s-delete to suppress objectproperty or dataproperty in data stored in my fuseki server, but I haven't found anything useful. And there is no update or suppress tools accessible by the browser.
Thanks in advance.

s-delete executes part of the SPARQL Graph Store Protocol which operaes on whole graphs only. It is an HTTP delete on a named graph.
To modify part of a graph, you need SPARQL Update, and so use s-update.
The delete command, using the DELETE WHERE short form might be:
DELETE WHERE {?s <http://www.semanticweb.org/ds/dependsOfExchange> ?o}
or the GRAPH version.

Related

Query a local ttl file using SPARQL on Virtuoso Conductor?

I am trying to learn SPARQL and I am trying to query a local ttl file which is my downloads
The path is : C:/Users/abc/Downloads/human-instructions-english-wikihow/en_0_rdf_result.ttl
SELECT ?s ?p ?o
FROM <C:/Users/abc/Downloads/human-instructions-english-wikihow/en_0_rdf_result.ttl>
WHERE {?s ?p ?o}
LIMIT 1000
So I am trying to execute a very simple query like this but it does not return any output.
I understand we have to put a SPARQL endpoint or something with 'http' in FROM but this file is on my Downloads and I cant seem to figure out what would be the endpoint.
Please, help me with this. Thanks.
(If you haven't already, you need to install the Virtuoso Sponger Middleware module, cartridges_dav.vad, for your version of Virtuoso Enterprise/Commercial Edition or Open Source Edition.)
First, you need to add this line to the top of your SPARQL query --
define get:soft "replace"
That "define pragma" is a SPARQL extension, which tells Virtuoso to resolve remote URLs it encounters in the rest of the query.
Then, you need to use a full URI for the target file. This may be a file: scheme URI, IFF --
the URI is properly constructed
the target file is accessible through the filesystem where Virtuoso is running
the directory holding the target file is included in the DirsAllowed parameter in the virtuoso.ini file
Also see How to import JSON-LD into Virtuoso.

How to completely delete an RDF node/instance from a graph database?

Good day, I am using Graphdb to store some triples as seen in the image below. This particular RDF node uses a regular URI http://example/regular/uri. What I wish to do is to not only completely delete all properties attached to this node, but also delete the node itself. (with the result that http://example/regular/uri does not appear in the graph database any longer)
So far I am only able to delete all properties, but I am not able to delete the actual RDF node itself. It seemed rather simple, but the more I research online, the more this seems impossible unless clearing the complete graph.
I have tried simple "delete where" queries as shown in example 11 of SPARQL documentation. And i have also tried using simple "delete where"-queries using the wildcard operator as shown in the query below:
Is there a way to delete such RDF nodes?
Thanks in advance!
A node exists in a graph as long as there is one or more triples with that node in subject or object position. So the easiest way would be to issue two delete statements, one deleting all statements with the node in subject position and one deleting all statements with the node in object position. But if you need/want to do it with a single operation you can do that as well with filters.
Here is a sample that delete uri://node/to/delete from uri://my/graph :
DELETE { GRAPH <uri://my/graph> {
?s ?p ?o .
}}
USING <uri://my/graph>
WHERE {
{
?s ?p ?o . VALUES ?s { <uri://node/to/delete>}
} UNION {
?s ?p ?o . VALUES ?o { <uri://node/to/delete>}
}
}

Setting to query only Default Graph and exclude Named Graphs

In the GraphDB documentation, I see that "the dataset’s default graph contains the merge of the database’s default graph AND all the database named graphs." This means that "if a statement ex:x ex:y ex:z exists in the database in the graph ex:g" then a query such as SELECT * { ?s ?p ?o } will return the triple ex:x ex:y ex:z
I am wondering if there is a setting which can be triggered either via the web interface or via the RDF4J/OpenRDF API which will disable this behavior in a specified GraphDB repository. That is, for the purposes of my project I would prefer to have triples which are stored in named graphs to only appear in results which specifically query that named graph.
I have not seen anything like this searching through the documentation or on the settings available on the web interface, but maybe somebody here knows something I don't.
EDIT: I am not looking for a SPARQL solution to this problem. I know that I can query just the default graph using SPARQL, but I want to be able to use the query SELECT * { ?s ?p ?o } and only see results which are in the default graph by default.
GraphDB/RDF4J have a different interpretation than Jena how to query the default graph. The only easy way to query only explicit statements in the default graph is to use the special graph sesame:nil. The SPARQL-based solution is to write:
PREFIX sesame: <http://www.openrdf.org/schema/sesame#>
SELECT ?s ?p ?o
FROM sesame:nil
WHERE {
?s ?p ?o .
} LIMIT 100
I don't think there is any easy non-SPARQL based solution like changing a configuration option or even use this special graph over the SPARQL Graph Store protocol.

Apache Marmotta Delete All Graphs using SPARQL Update

I am trying to clear all loaded graphs into my Apache Marmotta instance. I have tried several SPARQL queries to do so, but I am not able to remove the RDF/XML graph that I imported. What is the appropriate syntax to do so?
Try this query:
DELETE WHERE { ?x ?y ?z }
Be careful, as it deletes every triple in the database, including the built-in ones of Marmotta.
A couple of things I did for experimenting:
I downloaded the source code of Marmotta and used the Silver Searcher tool for searching for DELETE queries with the following command:
ag '"DELETE '
This did not help much.
I navigated to the Marmotta installation directory and watched the debug log:
tail -f marmotta-home/log/marmotta-main.log
This showed that the parser is not able to process the query DELETE DATA { ?s ?p ?o }. The exception behind the "error while executing update" was:
org.openrdf.sail.SailException: org.openrdf.rio.RDFParseException: Expected an RDF value here, found '?' [line 8]
[followed by a long stacktrace]
This shows that the parser does not allow variables in the query after DELETE DATA.
Based on a related StackOverflow answer, I tried CLEAR / CLEAR GRAPH / DROP / DROP GRAPH, but they did not work.
I tried many combinations of DELETE, *, ?s ?p ?p and accidentally managed to get it working with the DELETE WHERE construct. According to the W3C documentation:
The DELETE WHERE operation is a shortcut form for the DELETE/INSERT operation where bindings matched by the WHERE clause are used to define the triples in a graph that will be deleted.

How to create a SPARQL endpoint using Virtuoso?

I have just setup Virtuoso and I have loaded an OWL file (created with Protege software) present on my local machine in to Virtuoso using the following code:
SQL> DB.DBA.RDF_LOAD_RDFXML_MT (file_to_string_output ('antibiotics.owl'), '', 'http://myexample.com');
Now, my question is how do I access the URI myexample.com ? How do I create a SPARQL endpoint in Virtuoso so that I can query it?
No need to create a sparql endpoint, since it's already there.
Check the inserted RDF data on your Virtuoso instance sparql endpoint http://cname:port/sparql (usually: http://localhost:8890/sparql). To do some test queries, use the web interface of Virtuoso (the conductor) http://localhost:8890/conductor and go to the 'Linked Data' tab.
Enter a query like:
SELECT ?s ?p ?o
FROM <http://myexample.com>
WHERE {?s ?p ?o}
LIMIT 1000
to get started.
You can also query directly from the vsql command line by adding 'SPARQL ' in front of your sparql query.
To get results in a specific format directly via html get request:
http://localhost:8890/sparql?query=(YourQueryUriEncodedWithout())&format=json
For a more detailed answer, consult the documentation here:
http://docs.openlinksw.com/virtuoso/rdfsparql.html
Points of interest:
16.2.3.15. SPARQL Endpoint with JSON/P Output Option: Curl Example
16.2.5. SPARQL Inline in SQL
If you still want your own endpoint:
16.2.3.4.6. Creating and Using a SPARQL-WebID based Endpoint
Best regards...