Enabling reasoner on a virtual graph

I have an ontology, and I am wondering if the reasoner can be enabled with the GRAPH Component.

First let right the query where I am doing the reasoning

SELECT *  
{ 
    GRAPH <virtual://Customers> {
        ?s a ?c
    }
    ?c rdfs:subClassOf vcard:Individual
}

Ideally I would much prefer to let the stardog reasoner do this for me. And simply have something a kind to

   SELECT *  
    { 
        GRAPH <virtual://Customers/reasoning> {
            ?s a ?c
        }
    }

like I would if I was calling a real SPARQL endpoint

SELECT *  
{ 
    {
        SERVICE <http://admin:admin@localhost:5820/example3/query/reasoning> {
            ?s a vcard:Individual
        }
    }
}

Is reasoning on virtual graph supported, if so what the syntax to enable it.

Thanks
-Serge

What type of virtual graph did you create? We don't currently support variable type or variable predicate queries on virtual graphs with reasoning. However, an error should be returned. Can you share the query plan?

You are correct, enabling reasoning locally will cause an issue, similar to how it was describe in this post: Behaviour with federation and reasoning.

A workaround was to ask the service to do the reasoning remotely. Let re-use the queries in my previous post.

If I do a virtual import in database example3, I can use the following

 SELECT *  
{ 
    {
        SERVICE <http://admin:admin@localhost:5820/example3/query/reasoning> {
            ?s a vcard:Individual
        }
    }
}

Reasoning works because I added /reasoning at the end of my service endpoint. It done on the remote endpoint but that fine.

My question is, is there a way to achieve the same thing within a virtual add graph? I understand the performance would probably be impacted, but only looking at using T-box type of inferencing.

no worries, Was hoping there an undocumented option.

Is this a SPARQL virtual graph? If so, the sparql.url can include the reasoning path element in the URL and it should function as you need.

Virtual graphs in general only point to an upstream data source and whether reasoning is done there or not is unknown to Stardog.

thanks that answers my question. There is no SPARQL query rewriting of any kind done by the virtual service.

I guess would not be trivial to support. Anyway was just curious since I was playing with virtual graph today.

Thanks
-Serge

These are the main limitations but we do support reasoning over virtual graphs in general. Can you share which database is underlying your virtual graph? This might shed some light on things. If you're running a query with reasoning which is not producing the expected results (and not using a variable type or property), we can help you debug that.

I have this query

SELECT * 
WHERE {
    GRAPH <virtual://Customers> {
        ?s a ex:Customer 
    }
}

which return a list of customer.

Now I modify the query to be

   SELECT * 
    WHERE {
        GRAPH <virtual://Customers> {
            ?s a vcard:Individual
        }
    }

An execute it on a database with reasoning that has a rule

ex:Customer rdfs:subClassOf vcard:Individual

I would expect at least the same list to be return (in my case the exact same one) but no record is return. If I ask for the plan, it's empty.

I don't believe ?s is considered a variable type or variable predicate query, or is it.

To reproduce, is simple you can use any virtual graph that as rdfs:Class, and create a DB with the rule above.

-Serge

Those are type/classes. You would need to use rdfs:subClassOf instead of rdfs:subPropertyOf.

sorry that was in the post only. I do have a subClassOf

image

(I fixed my previous post)

Can you double check the prefixes of the ex:Customer used in the query and the rule?

Also check that you haven't somehow disabled the database option "Flag to enable reasoning over virtual graphs and SERVICE clauses." (reasoning.virtual.graph.enabled)

sure they are converted from the prefix registered with the DB by studio, but to confirmed that they are the same I looked at the json

From rule
{
"s": {
"type": "uri",
"value": "https://example.org/Customer"

From virtual graph

    "c": {
      "type": "uri",
      "value": "https://example.org/Customer"

They are indeed the same

Are you using Studio to enable reasoning for the query? Have you defined multiple reasoning schemas?

Confirm that reasoning is enabled for virtual graph
image

Using out of the box config. I loaded my rule with a turtle file. It is loaded in a namegraph by itself however, let me see if I load it in the default graph what happens.

Can you try inserting the data locally and see if the reasoning query works? It's gotta be something simple somewhere. This is a pretty straightforward query.

Before doing anything, I deleted the database and the virtual graph. During my tests, I often reseted either the database or the virtual graph but never both at the same time. I found it weird that there was no query plan so wanted to start from a clean slate thinking maybe something is not being cleanup properly.

Anyway , after resetting my installation and reloading exactly the same data , inference is working now. Maybe a simple server restart would of suffice, should of tried that first, but just happy it now works.

Thank for your help @jess

Glad it's working. Let us know if you have any further questions or issues.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.