Author: matt.voysey
Description:
Using SMW 1.6.1 and SMWSparqlStore to use external triple store (TDB via Fuseki). A semantic query of the form:
{{#ask: [[Age::<75]] }}
Generates the following SPARQL query (namespace prefixes omitted):
SELECT DISTINCT ?result WHERE {
?result swivt:wikiPageSortKey ?resultsk .
?result property:Age ?v1 .
{ FILTER ( ?v1 <= "75"^^xsd:double )
}
}
ORDER BY ASC(?resultsk)
OFFSET 0
LIMIT 51
The above returns no results, because the FILTER is placed in a different group to the query - see the SPARQL Query Spec section "5.2.2 Scope of Filters" (http://www.w3.org/TR/rdf-sparql-query/#scopeFilters). Indeed, testing the same form of query using dbpedia's Virtuoso SPARQL server yields the error "Virtuoso 37000 Error SP031: SPARQL compiler: Variable 'v1' is used in subexpressions of the query but not assigned". I'm not sure it's valid SPARQL to filter within a graph with no variables.
The same problem also causes Special:SearchByProperty to not return any "nearby values" results for numeric properties.
I traced the source of this rogue nested group to SMW_SparqlStoreQueryEngine buildPropertyCondition method, around line 713:
$innerConditionString = $innerCondition->getCondition() . $innerCondition->getWeakConditionString();
if ( $innerConditionString != '' ) { $condition .= "{ $innerConditionString}\n" ; }
Removing the '{' and '}' characters from the above fixes the problems and the queries then work OK, but I'm not sure whether it will break anything else.
Version: unspecified
Severity: normal