-
Notifications
You must be signed in to change notification settings - Fork 45
/
console-demo.out
65 lines (64 loc) · 3.21 KB
/
console-demo.out
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
\,,/
(o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
gremlin> :install org.opencypher.gremlin cypher-gremlin-console-plugin 1.0.0
cypher-gremlin-console-plugin, 1.0.0] - restart the console to use [opencypher.gremlin]
gremlin> :plugin use opencypher.gremlin
==>opencypher.gremlin activated
gremlin> // Test Gremlin connection
==>true
gremlin> :remote connect tinkerpop.server conf/janusgraph.yaml
==>Configured localhost/127.0.0.1:8182
gremlin> :> g.V().groupCount().by(label()).unfold()
==>Star=6
==>StarSystem=3
==>Planet=10
gremlin> // Connect to Cypher for Gremlin Server Plugin
==>true
gremlin> :remote connect opencypher.gremlin conf/janusgraph.yaml
==>Configured localhost/127.0.0.1:8182
gremlin> :> MATCH (n) RETURN labels(n)[0] as label, count(n) as count
==>[label:Star,count:6]
==>[label:StarSystem,count:3]
==>[label:Planet,count:10]
gremlin> :> MATCH (p:Planet)-[orbit:ORBITS]->(:Star {name: 'Sun'}) WHERE 2.3 < orbit.au < 3.3 RETURN p AS planet
==>[planet:[_type:node,name:Ceres,_id:4096,_label:Planet]]
gremlin> :> EXPLAIN MATCH (p:Planet)-[orbit:ORBITS]->(:Star {name: 'Sun'}) WHERE 2.3 < orbit.au < 3.3 RETURN p AS planet
==>[translation:g.V().as('p').hasLabel('Planet').outE('ORBITS').has('au', gt(2.3d)).has('au', lt(3.3d)).inV().hasLabel('Star').has('name', eq('Sun')).select('p').project('planet').by(__.valueMap(true)),options:[EXPLAIN]]
gremlin> :> MATCH (p:Planet)-[*2]->(ss:StarSystem) RETURN ss.name AS system, count(p) AS planets
==>[system:Solar System,planets:9]
==>[system:Alpha Centauri,planets:1]
gremlin> complexQuery = """
......1> MATCH (sun:Star {name: 'Sirius A'})-[*1..2]-(sys:StarSystem)
......2> OPTIONAL MATCH (p:Planet)-[:ORBITS]->(s:Star)-[:MEMBER_OF]->(sys)
......3> WHERE s.type IN ['K', 'G', 'B', 'F', 'O', 'A', 'M']
......4> WITH sys.name AS system, p.name AS planet
......5> ORDER BY planet
......6> RETURN system, collect(planet) AS planets
......7> """
MATCH (sun:Star {name: 'Sirius A'})-[*1..2]-(sys:StarSystem)
OPTIONAL MATCH (p:Planet)-[:ORBITS]->(s:Star)-[:MEMBER_OF]->(sys)
WHERE s.type IN ['K', 'G', 'B', 'F', 'O', 'A', 'M']
WITH sys.name AS system, p.name AS planet
ORDER BY planet
RETURN system, collect(planet) AS planets
gremlin> :> @complexQuery
==>[system:Sirius,planets:[]]
==>[system:Solar System,planets:[Ceres,Earth,Jupiter,Mars,Mercury,Neptune,Saturn,Uranus,Venus]]
==>[system:Alpha Centauri,planets:[Proxima Centauri b]]
gremlin> // Client-side translation
==>true
gremlin> :remote connect opencypher.gremlin conf/neptune.yaml translate neptune
==>Configured stas.cdg7wy6xrah2.us-east-2.neptune.amazonaws.com/172.31.10.133:8182
gremlin> :> MATCH (p:Planet)-[orbit:ORBITS]->(:Star {name: 'Sun'}) WHERE 2.3 < orbit.au < 3.3 RETURN p AS planet
==>[planet:[_type:node,name:Ceres,_id:ecb4b95f-9847-0982-a8a8-5bb34374b285,_label:Planet]]
gremlin> // Combining Cypher and Gremlin
==>true
gremlin> g = EmptyGraph.instance().traversal(CypherTraversalSource.class).withRemote('conf/remote-graph.properties')
==>cyphertraversalsource[emptygraph[empty], standard]
gremlin> g.cypher('MATCH (p:Planet) RETURN p').select("p").outE().label().dedup()
==>ORBITS
gremlin>