I followed the steps you described. Created a Designer project, added two classes, added relationships, and added the rule (find the Designer project attached below). I published the model including the rule to an empty database and insert the data as you suggested. Specifically, in my cases I added
INSERT DATA {
:A a <tag:stardog:designer:Test1:model:Class1> .
:B a <tag:stardog:designer:Test1:model:Class2> .
:A <tag:stardog:designer:Test1:model:created> :B .
}
When you publish your Designer project, make sure to also checke the box "Publish Inference Rules". Or maybe you have a mismatch in the IRIs you are using?
I have copied your exact steps and while I can get "B" to display via the "createdBy" relationship in explorer I do not get any results when querying via Stardog Studio.
The inference rules are published when the designer project and model is published to the database.
Is this something related to the context being selected when Inserting data and querying the data?
I have tried every available context in Stardog Studio and I get no results when querying the inferred relationship
I don't think it's related to the context/graph. When you execute the INSERT DATA query, the data will be added to the default graph and the SELECT query also is evaluated over the default graph.
Can you "Run Profiler" (in the dropdown next to "Show Plan") with your query in Studio and share the profiling results here? Make sure to enable Reasoning in Studio.
As indicated in the FROM statement of your profiling results, the query is executed only over the named graph tag:stardog:designer:example:model which only contains your model (that is, not the instance data you added).
Try to either unselect any named graphs in Studio:
That's strange. Do you get any results when you run the query with the body (i.e., IF part) of your rule:
SELECT *
FROM stardog:context:local
{
?obj_0 a <tag:stardog:designer:example:model:Class1> .
?obj_1 a <tag:stardog:designer:example:model:Class2> .
?obj_0 <tag:stardog:designer:example:model:created> ?obj_1 .
}
If this doesn't match any results, then there are not matching instance for which the createdBy property can be inferred. This probably means, the data you inserted does not match your model (e.g., IRIs of the classes and properties).
If this is the case, you can run
Ok, that seems fine. You can use the CLI (which is part of the current release, see docs) to verify whether your schema was parsed and is set correctly using the reasoning command. For example, if your instance runs of stardog cloud the command would look like as follows:
This should print the schema that is used for inference by the query engine.
If you haven't already, you can set the password for your user in Studio via the Security tab using the three-dot menu at the top right and "Change Password".
Thanks for your time. I managed to resolve the reasoning problem.
I needed to select the specific reasoning schema when running the query rather than using the default configuration. This now works for all my ontologies when I select the schema.