sparna-git / Sparnatural

Sparnatural : Typescript visual SPARQL query builder for knowledge graphs, configurable with SHACL
http://sparnatural.eu
GNU Lesser General Public License v3.0
205 stars 34 forks source link

Federated queries via string matching #605

Open CFGrote opened 1 week ago

CFGrote commented 1 week ago

If I understand correctly, setting up a federated query requires that the subject node of the config-core:sparqlService annotated property exists both in the local graph and in the remote (federated) graph. E.g. in the documented example, the node Museum_Wikidata exists in the local graph and in Wikidata.

In my case, local and remote graphs only share common Literals, not URIs.

For example, my local graph has

local:mynode local:crossref_id "abc123" .

and the remote graph has

remote:somenode remote:id "abc123" .

and a query to cross link these two would hence read

select * where {
   ?l_node local:crossref_id ?local_id .

   service <http://remote.net/sparql> {
     ?r_node a remote:someClass;
                    remote:id ?remote_id .
    }
    values ?local_id {?remote_id} .

or something similar.

My question is if (and how) such a query could be configured in Sparnatural. I hope my example is clear enough. Thanks for any hint.

tfrancart commented 1 week ago

If I understand correctly, setting up a federated query requires that the subject node of the config-core:sparqlService annotated property exists both in the local graph and in the remote (federated) graph.

I think it could work using inverse property paths. There is a subtlety, let me rephrase : it requires that the node in the subject position (in terms of query writing) of the config-core:sparqlService annotated property exists both in the local graph and in the remote (federated) graph.

I think it could work if you use an inverse property path on the sparqueSrevice-annotated property:

ex:myPropertyShape
  sh:path [ sh:inversePath remote:id ] ;  

the SPARQL query will then be something like:

select ?l_node ?r_node where {
   ?l_node local:crossref_id ?theId .

   service <http://remote.net/sparql> {
    ?theId ^remote:id  ?r_node;
    }

could you try this and let me know ?

Also let me know if you have a publicly available deployment !