The filter in the Sparql query does not work

I am running a sparql query against one of my sparql endpoints, which only supports Sparql 1.0.

I am trying to get a list of users from a store using the following query:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX tmp: <http://example.com/schema/temp#>
PREFIX resource: <http://example.com/2010/record/schema#>
Describe ?userURI
WHERE 
{
    ?userURI rdf:type resource:User.
    OPTIONAL
    {               
        ?userURI tmp:dataCleanupStatus ?cleanUpStatus.
        ?userURI tmp:lastDataCleanupDate ?cleanUpDate.                  
    }
    FILTER 
    ( 
        (!bound(?cleanUpStatus) || ?cleanUpStatus !="Running")
    )
                    FILTER(    
        (!bound(?cleanUpDate) || ?cleanUpDate < "2012-04-11" )
    )

}

With the above query, I am trying to get users where:

  • Either clearing the triple state does not exist, or the status does not work "
  • clearnUpDate triple either does not exist or is less than the specified date.

it does not return the record that it should return.

You could say that I should use the xsd functions , but they are only supported in Sparql 1.1


I ask for advice.

Modified request:


PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX tmp: <http://example.com/schema/temp#>
PREFIX resource: <http://example.com/2010/record/schema#>
Describe ?userURI
WHERE 
{
    ?userURI rdf:type resource:User.
    OPTIONAL
    {               
        ?userURI tmp:dataCleanupStatus ?cleanUpStatus.

    }

    OPTIONAL
    {               
        ?userURI tmp:lastDataCleanupDate ?cleanUpDate.                  
    }
    FILTER 
    ( 
        !bound(?cleanUpStatus) || ?cleanUpStatus !="Running"
    )
    FILTER
    (    
        !bound(?cleanUpDate) || ?cleanUpDate < "2012-04-11" 
    )

}

+3
source share
1 answer

, , , xsd:date . .

, :

?cleanUpDate < "2012-04-11"^^xsd:date    # Compare against date
STR(?cleanUpDate) < "2012-04-11"         # Convert to string before comparison

, OPTIONAL ?cleanUpStatus ?cleanUpDate.

+6

All Articles