CredentialEngine / CredentialRegistry

Repository for development of the Credential Registry
Apache License 2.0
12 stars 10 forks source link

Search API error with multiple subClassOf matches #718

Closed siuc-nate closed 3 weeks ago

siuc-nate commented 1 month ago

This query works:

{
  "@type": { 
    "search:value": "ceterms:Credential", 
    "search:matchType": "search:subClassOf" 
  }
}

However, this query returns an error:

{
  "@type": [
    { 
      "search:value": "ceterms:Credential", 
      "search:matchType": "search:subClassOf" 
    },
    { 
      "search:value": "ceterms:LearningOpportunityProfile", 
      "search:matchType": "search:subClassOf" 
    }
  ]
}

image

Part of the problem seems to be the array itself, as these both return the same error:

{
  "@type": [
    { 
      "search:value": "ceterms:Credential", 
      "search:matchType": "search:subClassOf" 
    }
  ]
}
{
  "@type": [
    { 
      "search:value": "ceterms:Credential", 
      "search:matchType": "search:subClassOf" 
    },
    "ceterms:LearningOpportunityProfile"
  ]
}

I also tried:

{
  "search:termGroup": [
    {
      "@type": [
        { 
          "search:value": "ceterms:Credential", 
          "search:matchType": "search:subClassOf" 
        }
      ]
    },
    {
      "@type": [
        { 
          "search:value": "ceterms:LearningOpportunityProfile", 
          "search:matchType": "search:subClassOf" 
        }
      ]
    }
  ]
}

and:

{
  "search:termGroup": {
    "search:value": [
      {
        "@type": [
          { 
            "search:value": "ceterms:Credential", 
            "search:matchType": "search:subClassOf" 
          }
        ]
      },
      {
        "@type": [
          { 
            "search:value": "ceterms:LearningOpportunityProfile", 
            "search:matchType": "search:subClassOf" 
          }
        ]
      }
    ]
  }
}

with no luck.

For what it's worth, this query works.

{
  "@type": { 
    "search:value": [ 
      "ceterms:Credential", 
      "ceterms:LearningOpportunityProfile" 
    ], 
    "search:matchType": "search:subClassOf" 
  }
}

That's probably good enough for most cases, but if I (for some reason) didn't want the subclasses of Learning Opportunity Profile, I wouldn't be able to filter them out. All three of these return the same number of results:

{
  "@type": { 
    "search:value": [ 
      "ceterms:Credential", 
      "ceterms:LearningOpportunityProfile" 
    ], 
    "search:matchType": "search:subClassOf" 
  },
  "!@type": [
    "ceterms:Course",
    "ceterms:LearningProgram"
  ]
}
{
  "@type": { 
    "search:value": [ 
      "ceterms:Credential", 
      "ceterms:LearningOpportunityProfile" 
    ],
    "!search:value": [
      "ceterms:Course",
      "ceterms:LearningProgram"
    ],
    "search:matchType": "search:subClassOf" 
  }
}
excelsior commented 3 weeks ago

@siuc-nate The issue has been been fixed. Now this query works:

{
  "@type": [
    { 
      "search:value": "ceterms:Credential", 
      "search:matchType": "search:subClassOf" 
    },
    { 
      "search:value": "ceterms:LearningOpportunityProfile", 
      "search:matchType": "search:subClassOf" 
    }
  ]
}

…and returns the same results as this query:

{
  "@type": { 
    "search:value": [ 
      "ceterms:Credential", 
      "ceterms:LearningOpportunityProfile" 
    ], 
    "search:matchType": "search:subClassOf" 
  }
}
excelsior commented 3 weeks ago

However, this query does NOT return anything:

{
  "search:termGroup": {
    "search:value": [
      {
        "@type": [
          { 
            "search:value": "ceterms:Credential", 
            "search:matchType": "search:subClassOf" 
          }
        ]
      },
      {
        "@type": [
          { 
            "search:value": "ceterms:LearningOpportunityProfile", 
            "search:matchType": "search:subClassOf" 
          }
        ]
      }
    ]
  }
}

Although it doesn't fail, this format (i.e. branching within a search:value clause) isn't supported by the engine.

siuc-nate commented 3 weeks ago

Thank you.