Skip to content

Commit

Permalink
Improve README (#262)
Browse files Browse the repository at this point in the history
Signed-off-by: Dwitry dwitry@users.noreply.github.com
  • Loading branch information
dwitry authored Apr 15, 2019
1 parent 53bc302 commit fa00284
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 1 deletion.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ Cypher query is translated to one of Gremlin representations (Gremlin Groovy str

### Gremlin Console

[Gremlin Console plugin](tinkerpop/cypher-gremlin-console-plugin) that enables client-side translation of Cypher queries or communication with a Cypher-enabled Gremlin Server (click to play):
[Gremlin Console plugin](tinkerpop/cypher-gremlin-console-plugin) that enables client-side translation of Cypher queries
or communication with a Cypher-enabled Gremlin Server (click to play/[view source](testware/integration-tests/src/test/resources/snippets/console-demo.out)):

<img src="https://drive.google.com/uc?export=view&id=1vncDfbO8o9Ef060SFOBmlQpt4v7etGrJ" />

Expand Down Expand Up @@ -98,6 +99,24 @@ client.execute(cypherQuery, (err, results) => {

See examples for [Gremlin-Java](tinkerpop/cypher-gremlin-server-plugin#gremlin-javagremlin-groovy), [Gremlin-Groovy](tinkerpop/cypher-gremlin-server-plugin#gremlin-javagremlin-groovy), [Gremlin-Python](tinkerpop/cypher-gremlin-server-plugin#gremlin-python) and [Gremlin.Net](tinkerpop/cypher-gremlin-server-plugin#gremlinnet)

### Cypher Traversal Source

For [Gremlin Console Plugin](https://github.com/opencypher/cypher-for-gremlin/tree/master/tinkerpop/cypher-gremlin-console-plugin#combining-cypher-and-gremlin) and [Gremlin Server Client](https://github.com/opencypher/cypher-for-gremlin/tree/master/tinkerpop/cypher-gremlin-server-client#cypher-traversal-source)
its possible to combine Cypher and Gremlin in single query. Traversal can start with `cypher` step that allows to run Cypher
query (which will be translated to Gremlin and works `withRemote`) then continue traversal using other Gremlin steps:

<!-- [freshReadmeSource](testware/integration-tests/src/test/java/org/opencypher/gremlin/snippets/CypherGremlinServerClientSnippets.java#cypherTraversalSource) -->
```java
CypherTraversalSource g = graph.traversal(CypherTraversalSource.class);

GraphTraversal<Map<String, Object>, String> query = g
.cypher("MATCH (n) RETURN n")
.select("n")
.outE()
.label()
.dedup();
```

## Quick Start

1. Run [Docker images](docker)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
\,,/
(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]
rbit.au < 3.3 RETURN p AS planetbit:ORBITS]->(:Star {name: 'Sun'}) WHERE 2.3 < o
==>[planet:[_type:node,name:Ceres,_id:4096,_label:Planet]]
2.3 < orbit.au < 3.3 RETURN p AS planetbit:ORBITS]->(:Star {name: 'Sun'}) WHERE
==>[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]]
nt(p) AS planetsH (p:Planet)-[*2]->(ss:StarSystem) RETURN ss.name AS system, cou
==>[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> """
'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
rbit.au < 3.3 RETURN p AS planetbit:ORBITS]->(:Star {name: 'Sun'}) WHERE 2.3 < o
==>[planet:[_type:node,name:Ceres,_id:ecb4b95f-9847-0982-a8a8-5bb34374b285,_label:Planet]]
gremlin> // Combining Cypher and Gremlin
==>true
mote('conf/remote-graph.properties')raversal(CypherTraversalSource.class).withRe
==>cyphertraversalsource[emptygraph[empty], standard]
)remlin> g.cypher('MATCH (p:Planet) RETURN p').select("p").outE().label().dedup(
==>ORBITS
gremlin>

0 comments on commit fa00284

Please sign in to comment.