fluree / core

Fluree releases and public bug reports
0 stars 0 forks source link

`rdfs:subClassOf` Inferencing Not Working in Queries #48

Open aaj3f opened 8 months ago

aaj3f commented 8 months ago

Description

This is observed when running server on feature/where-syntax-update (commit SHA 7f125ccae182d4df5b1850ee64301291cf414954)

Establishing an rdfs:subClassOf relationship between rdfs:Class entities is not currently allowing you to query for the parent class and see subClass entities returned

Steps to Reproduce

Create Ledger

{
    "@context": "https://ns.flur.ee",
    "ledger": "cookbook/base",
    "insert": [
        {
            "@id": "ex:freddy",
            "@type": "ex:Yeti",
            "schema:name": "Freddy"
        },
        {
            "@id": "ex:letty",
            "@type": "ex:Yeti",
            "schema:name": "Leticia"
        },
        {
            "@id": "ex:betty",
            "@type": "ex:Yeti",
            "schema:name": "Betty"
        },
        {
            "@id": "ex:andrew",
            "@type": "schema:Person",
            "schema:name": "Andrew Johnson"
        }
    ],
    "opts": {
        "defaultContext": {
            "ex": "http://example.org/",
            "f": "https://ns.flur.ee/ledger#",
            "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
            "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
            "schema": "http://schema.org/",
            "xsd": "http://www.w3.org/2001/XMLSchema#"
        }
    }
}

Add parent class relationships

{
  "@context": "https://ns.flur.ee",
  "ledger": "cookbook/base",
  "insert": [
      {
          "@id": "ex:Humanoid",
          "@type": "rdfs:Class"
      },
      {
          "@id": "ex:Yeti",
          "rdfs:subClassOf": { "@id": "ex:Humanoid" }
      },
      {
          "@id": "schema:Person",
          "rdfs:subClassOf": { "@id": "ex:Humanoid" }
      }
  ]
}

Query parent class for entities in subClass

{
    "from": "cookbook/base",
    "where": {
        "@id": "?s",
        "@type": "ex:Humanoid"
    },
    "select": {
        "?s": ["*"]
    }
}

// => 

[] // Previously this returned entities of `schema:Person` and `ex:Humanoid`
cap10morgan commented 7 months ago

fix: https://github.com/fluree/db/pull/662