I'm currently learning some sparql and I'm practicing on the following website with some statements:
http://data.semanticweb.org/snorql
However, I'm trying to execute the following statement:
SELECT DISTINCT ?author WHERE { ?paper swrc:author ?author FILTER(regex(?paper, "2006")) . } .
It says that there are no results. When I run the following query (without the filter):
SELECT DISTINCT ?paper WHERE { ?paper swrc:author ?author . }
I see that there are some papers with 2006 in it's string. I'm wondering why the first query is not returning these entries where there is 2006 in the ?paper string.
Could anyone help me with this?
SPARQL, short for “SPARQL Protocol and RDF Query Language”, enables users to query information from databases or any data source that can be mapped to RDF. The SPARQL standard is designed and endorsed by the W3C and helps users and developers focus on what they would like to know instead of how a database is organized.
Both of these languages give the user access to create, combine, and consume structured data. SQL does this by accessing tables in relational databases, and SPARQL does this by accessing a web of Linked Data.
"PREFIX", however (without the "@"), is the SPARQL instruction for a declaration of a namespace prefix. It allows you to write prefixed names in queries instead of having to use full URIs everywhere. So it's a syntax convenience mechanism for shorter, easier to read (and write) queries.
The RDF terms returned for ?paper
are all URIs. The REGEX
filter function doesn't work on URIs; it only works on strings. You can turn a URI into a string using the STR(…)
function. This will work:
FILTER(regex(STR(?paper), "2006"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With