Ubercoder
Ubercoder

Reputation: 741

Error running SPARQL query with FILTER and LIMIT

I am using http://dbpedia-live.openlinksw.com/sparql/ and running a SPARQL query using a FILTER, ORDER BY and LIMIT. Here is the query - it's supposed to return a sample of people and their names and birth dates:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?x0 ?name ?dob WHERE {
  ?x0 rdf:type foaf:Person.
  ?x0 rdfs:label ?name.
  ?x0 dbpedia-owl:birthDate ?dob.
  FILTER REGEX(?name,"[A-Z].*").
} ORDER BY ?name LIMIT 100

When I run the query it returns an internal error:

Virtuoso VECSL Error VECSL: Internal error, ssl refd before set, please report query to support
SPARQL query:
define sql:big-data-const 0 
#output-format:text/html
define sql:signal-unconnected-variables 1 define sql:signal-void-variables 1 define input:default-graph-uri <http://dbpedia.org> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?x0 ?name ?dob
WHERE {
?x0 rdf:type foaf:Person.
?x0 rdfs:label ?name.
?x0 dbpedia-owl:birthDate ?dob.
FILTER REGEX(?name,"[A-Z].*").
} ORDER BY ?name LIMIT 100

but if I comment out my FILTER using # the query runs OK. Has anyone seen this before? Is there an obscure error in my SPARQL or is it an internal error in the endpoint?

Upvotes: 2

Views: 775

Answers (2)

Ubercoder
Ubercoder

Reputation: 741

Based on everyone's help the answer is:

  1. The Virtuoso end-point that hosts http://dbpedia-live.openlinksw.com/sparql/ has a bug affecting FILTER and ORDER BY.

  2. A work-around is possible.

Code:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?x0 ?name2 ?dob WHERE {
  ?x0 rdf:type foaf:Person.
  ?x0 rdfs:label ?name.
  ?x0 dbpedia-owl:birthDate ?dob.
  FILTER REGEX(?name,"^[A-Z].*").
  BIND (str(?name) AS ?name2)
} ORDER BY ?name2 LIMIT 100

Basically it does a BIND and does the ordering and the limit on the new bound variable.

Upvotes: 2

Gilles-Antoine Nys
Gilles-Antoine Nys

Reputation: 1481

Actually, Virtuoso 8 doesnt support a query that involves an ORDER BY and a FILTER.

This issue has been reported since June 2017.

Upvotes: 4

Related Questions