hielsnoppe
hielsnoppe

Reputation: 2869

How to get `filter not exists` query working with ARC2?

I have an ARC2 based RDF store setup and filled with some data. The following query returns the expected results (all URIs of things of type vcard:Individual or foaf:Person) when I run it without the FILTER NOT EXISTS part:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX app: <http://example.com#>

SELECT ?person
WHERE {
  ?person rdf:type ?type .
  FILTER (?type = vcard:Individual || ?type = foaf:Person)
  FILTER NOT EXISTS {
    ?person app:id ?id
  }
}

When I try to exclude those things having the app:id property by running the full query, it fails with the following message:

Incomplete FILTER in ARC2_SPARQLPlusParser
Incomplete or invalid Group Graph pattern. Could not handle &quot;        FILTER NOT EXISTS {   &quot; in ARC2_SPARQLPlusParser

When testing the query in the query validator on sparql.org, there are no issues. Is there something wrong with my query that I am missing or is this a shortcoming of ARC2?

Can you think of an alternative query that I can try with ARC2 to get the desired result?

Upvotes: 0

Views: 450

Answers (1)

UninformedUser
UninformedUser

Reputation: 8465

ARC2 does not support SPARQL 1.1, thus, you have to use the common OPTIONAL-FILTER(!BOUND()) pattern:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX app: <http://example.com#>

SELECT ?person
WHERE {
  ?person rdf:type ?type .
  FILTER (?type = vcard:Individual || ?type = foaf:Person)
  OPTIONAL {
    ?person app:id ?id
  }
  FILTER ( !BOUND(?id) ) 
}

Upvotes: 3

Related Questions