@@ -27,6 +27,9 @@ Gremlin Compiler enables a particular query language to work on any TinkerPop-en
2727[[sparql-gremlin]]
2828== SPARQL-Gremlin
2929
30+ WARNING: The sparql-gremlin module is not included in the 4.0.0-beta.2 distribution. The examples in this
31+ section are presented as static code and will be restored in a future release.
32+
3033image::gremlintron.png[width=225]
3134
3235The SPARQL-Gremlin compiler, transforms link:https://en.wikipedia.org/wiki/SPARQL[SPARQL] queries into Gremlin
@@ -66,7 +69,7 @@ gremlin> :plugin use tinkerpop.sparql
6669Installing this plugin will download appropriate dependencies and import certain classes to the console so that they
6770may be used as follows:
6871
69- [gremlin-groovy,modern ]
72+ [source,groovy ]
7073----
7174graph = TinkerFactory.createModern()
7275g = traversal(SparqlTraversalSource).with(graph) <1>
@@ -98,7 +101,7 @@ The SPARQL-Gremlin compiler supports the following prefixes to traverse the grap
98101
99102Note that element IDs and labels are treated like normal properties, hence they can be accessed using the same pattern:
100103
101- [gremlin-groovy,existing ]
104+ [source,groovy ]
102105----
103106g.sparql("""SELECT ?name ?id ?label
104107 WHERE {
@@ -228,7 +231,7 @@ The following section presents examples of SPARQL queries that are currently cov
228231
229232Select all vertices in the graph.
230233
231- [gremlin-groovy,existing ]
234+ [source,groovy ]
232235----
233236g.sparql("""SELECT * WHERE { }""")
234237----
@@ -237,7 +240,7 @@ g.sparql("""SELECT * WHERE { }""")
237240
238241Select all vertices with the label `person`.
239242
240- [gremlin-groovy,existing ]
243+ [source,groovy ]
241244----
242245g.sparql("""SELECT * WHERE { ?person v:label "person" .}""")
243246----
@@ -246,7 +249,7 @@ g.sparql("""SELECT * WHERE { ?person v:label "person" .}""")
246249
247250Select the values of the properties `name` and `age` for each `person` vertex.
248251
249- [gremlin-groovy,existing ]
252+ [source,groovy ]
250253----
251254g.sparql("""SELECT ?name ?age
252255WHERE {
@@ -259,7 +262,7 @@ WHERE {
259262
260263Select only those persons who created a project.
261264
262- [gremlin-groovy,existing ]
265+ [source,groovy ]
263266----
264267g.sparql("""SELECT ?name ?age
265268WHERE {
@@ -273,7 +276,7 @@ WHERE {
273276
274277Select only those persons who are older than 30.
275278
276- [gremlin-groovy,existing ]
279+ [source,groovy ]
277280----
278281g.sparql("""SELECT ?name ?age
279282WHERE {
@@ -287,7 +290,7 @@ WHERE {
287290
288291Select the distinct names of the created projects.
289292
290- [gremlin-groovy,existing ]
293+ [source,groovy ]
291294----
292295g.sparql("""SELECT DISTINCT ?name
293296WHERE {
@@ -302,7 +305,7 @@ WHERE {
302305
303306Select the distinct names of all Java projects.
304307
305- [gremlin-groovy,existing ]
308+ [source,groovy ]
306309----
307310g.sparql("""SELECT DISTINCT ?name
308311WHERE {
@@ -318,7 +321,7 @@ WHERE {
318321
319322Select all persons who have developed a software in java using union.
320323
321- [gremlin-groovy,existing ]
324+ [source,groovy ]
322325----
323326g.sparql("""SELECT *
324327WHERE {
@@ -345,7 +348,7 @@ WHERE {
345348
346349Select all vertices with the label `person` and order them by their age.
347350
348- [gremlin-groovy,existing ]
351+ [source,groovy ]
349352----
350353g.sparql("""SELECT ?age ?name
351354WHERE {
@@ -359,7 +362,7 @@ WHERE {
359362
360363Select all vertices with the label `person` and group them by their age.
361364
362- [gremlin-groovy,existing ]
365+ [source,groovy ]
363366----
364367g.sparql("""SELECT ?age
365368WHERE {
@@ -388,7 +391,7 @@ WHERE {
388391Accessing the Meta-Property of a graph element. Meta-Property can be perceived as the reified statements in an RDF
389392graph.
390393
391- [gremlin-groovy,theCrew ]
394+ [source,groovy ]
392395----
393396g = traversal(SparqlTraversalSource).with(graph)
394397g.sparql("""SELECT ?name ?startTime
@@ -405,7 +408,7 @@ STAR-shaped queries are the queries that form/follow a star-shaped execution pla
405408can be perceived as path queries or neighborhood queries. For instance, getting all the information about a specific
406409`person` or `software`.
407410
408- [gremlin-groovy,existing ]
411+ [source,groovy ]
409412----
410413g.sparql("""SELECT ?age ?software ?lang ?name
411414WHERE {
@@ -422,7 +425,7 @@ WHERE {
422425The `sparql()`-step takes a SPARQL query and returns a result. That result can be further processed by standard Gremlin
423426steps as shown below:
424427
425- [gremlin-groovy,modern ]
428+ [source,groovy ]
426429----
427430g = traversal(SparqlTraversalSource).with(graph)
428431g.sparql("SELECT ?name ?age WHERE { ?person v:name ?name . ?person v:age ?age }")
0 commit comments