Using SERVICE to inject pragma into the query is not exact standard ... nor exactly spec-compliant :-)

I think that is trying to do something like a traversal of 1 to 4 in depth and get a picture: {0,4} includes the start.

Standard SPARQL has arbitrary length traversal and can't limit the depth.

WHERE {
   wd:Q720 wdt:P40* ?child .
   OPTIONAL { ?child wdt:P18 ?pic }
}



ARQ supports an extension - it's a feature that didn't make into the final SPARQL 1.1 spec (parse with syntax "ARQ", the default in Fuseki): this isn't necessary exactly the same:

SELECT ?child ?pic
WHERE {
   wd:Q720 wdt:P40{0,4} ?child .
   OPTIONAL { ?child wdt:P18 ?pic }
}

The other problem is the opaque wdt vocabulary - that's not a SPARQL issue, that's the vocab and data.

        Andy

(https://query.wikidata.org is a BlazeGraph installation)

On 05/03/17 16:44, A. Soroka wrote:
That is in no way a normal SPARQL query. I don't know where in particular you got it, but 
it is an example of Blazegraph/BigData's "GAS" API. It's not an example of 
idiomatic SPARQL at all.

https://wiki.blazegraph.com/wiki/index.php/RDF_GAS_API

That is a specialist extension API for one product's particular capability.

You can refer to any number of good tutorials for how to write normal SPARQL. 
Jena itself maintains one:

https://jena.apache.org/tutorials/sparql.html


---
A. Soroka
The University of Virginia Library

On Mar 5, 2017, at 11:37 AM, Laura Morales <[email protected]> wrote:

Could you be more specific about these intuitions and difficulties?

with other query languages such as gremlin you start from a vertex (or set of vertices), and follow links 
(predicates). This is very intuitive, because it resemble the picture of a graph that I have in mind. For 
example, I can start from the vertex "Bruce Springsteen" and follow its out-links 
"some_namespace:song". Very easy to understand and work with. SPARQL, at least to me, seems to be 
way more intricate, messy, verbose, and ultimately difficult to understand. Just look at this query (copied 
from wikidata examples) for a query as simple as "Children of Genghis Khan".... I barely understand 
how to read it to be honest

#Children of Genghis Khan
#added before 2016-10
#defaultView:Graph

PREFIX gas: <http://www.bigdata.com/rdf/gas#>

SELECT ?item ?itemLabel ?pic ?linkTo
WHERE
{
 SERVICE gas:service {
   gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.SSSP" ;
               gas:in wd:Q720 ;
               gas:traversalDirection "Forward" ;
               gas:out ?item ;
               gas:out1 ?depth ;
               gas:maxIterations 4 ;
               gas:linkType wdt:P40 .
 }
 OPTIONAL { ?item wdt:P40 ?linkTo }
 OPTIONAL { ?item wdt:P18 ?pic }
 SERVICE wikibase:label {bd:serviceParam wikibase:language "en" }
}

Reply via email to