Tutorial: Importing the movie Database from Neo4j

In this tutorial we will follow the steps described in the Import from Neo4j using GraphML section to import the Neo4j's movie example database into OrientDB.

We will also provide some examples of queries using the OrientDB's MATCH syntax, making a comparison with the corresponding Neo4j's Cypher query language.

For general information on the possible Neo4j to OrientDB migration strategies, please refer to the Import from Neo4j section.

Neo4j and Cypher are registered trademark of Neo Technology, Inc.

Exporting from Neo4j

Assuming you have already downloaded and unpacked the Neo4j Shell Tools, and restarted the Neo4j Server, as described in the Section Exporting GraphML, you can export the movie database using neo4j-shell with a command like the following one:


Welcome to the Neo4j Shell! Enter 'help' for a list of commands
NOTE: Remote Neo4j graph database service 'shell' at port 1337

neo4j-sh (?)$ export-graphml -t -o d:/movie.graphml
Wrote to GraphML-file d:/movies.graphml 0. 100%: nodes = 171 rels = 253 properties = 564 time 270 ms total 270 ms

In the example above the exported movie graph is stored under D:\movie.graphml.

Importing into OrientDB

In this tutorial we will import in OrientDB the file movie.graphml using the OrientDB's Console. For other GraphML import methods, please refer to the section Importing GraphML.

The OrientDB's Console output generated during the import process is similar to the following (note that first we create a movie database using the command CREATE DATABASE, and then we do the actual import using the command IMPORT DATABASE):


OrientDB console v.2.2.8-SNAPSHOT (build [email protected]; 2016-08-23 14:38:49+0000) www.orientdb.com
Type 'help' to display all the supported commands.
Installing extensions for GREMLIN language v.2.6.0

orientdb> CREATE DATABASE PLOCAL:D:/orientdb/orientdb-enterprise-2.2.8/databases/movie

Creating database [PLOCAL:D:/orientdb/orientdb-enterprise-2.2.8/databases/movie] using the storage type [PLOCAL]...
Database created successfully.

Current database is: PLOCAL:D:/orientdb/orientdb-enterprise-2.2.8/databases/movie
orientdb {db=movie}> IMPORT DATABASE D:/movie.graphml

Importing GRAPHML database from D:/movie.graphml with options ()...
Done: imported 171 vertices and 253 edges
orientdb {db=movie}>

As you can see from the output above, as a result of the import 171 vertices and 253 edges have been created in OrientDB. This is exactly the same number of nodes and relationships exported from Neo4j.

For more tips and tricks related to the import process, please refer to this section.

Query Comparison

Once the movie database has been imported into OrientDB, you may use several ways to access its data.

The MATCH syntax and the tool Studio can be used, for instance, in a similar way to the Neo4j's Cypher and Browser.

The following sections include a comparison of the Neo4j's Cypher and OrientDB's MATCH syntax for some queries that you can execute against the movie database.

Find the actor named "Tom Hanks"

Neo4j's Cypher OrientDB's MATCH
MATCH (tom:Person {name: "Tom Hanks"}) RETURN tom MATCH {class: Person, as: tom, where: (name = 'Tom Hanks')} RETURN $pathElements

Find the movie with title "Cloud Atlas"

Neo4j's Cypher OrientDB's MATCH
MATCH (cloudAtlas:Movie {title: "Cloud Atlas"}) RETURN cloudAtlas MATCH {class: Movie, as: cloudAtlas, where: (title = 'Cloud Atlas')} RETURN $pathElements

Find 10 people

Neo4j's Cypher OrientDB's MATCH
MATCH (people:Person) RETURN people.name LIMIT 10 MATCH {class: Person, as: people} RETURN people.name LIMIT 10

Find the movies released in the 1990s

Neo4j's Cypher OrientDB's MATCH
MATCH (nineties:Movie) WHERE nineties.released > 1990 AND nineties.released < 2000 RETURN nineties.title MATCH {class: Movie, as: nineties, WHERE: (released > 1990 AND released < 2000 )} RETURN nineties.title

List all Tom Hanks movies

Neo4j's Cypher OrientDB's MATCH
MATCH (tom:Person {name: "Tom Hanks"})-[:ACTED_IN]->(tomHanksMovies) RETURN tom, tomHanksMovies MATCH {class: Person, as: tom, where: (name = 'Tom Hanks')}-ACTED_IN->{as: tomHanksMovies} RETURN $pathElements

Find out who directed "Cloud Atlas"

Neo4j's Cypher OrientDB's MATCH
MATCH (cloudAtlas {title: "Cloud Atlas"})<-[:directed]-(directors) return="" directors.name="" <="" td=""> MATCH {class: Movie, as: cloudAtlas, where: (title = 'Cloud Atlas')}<-directed-{as: directors}="" return="" directors.name="" <="" td="">

Find Tom Hanks' co-actors

Neo4j's Cypher OrientDB's MATCH
MATCH (tom:Person {name:"Tom Hanks"})-[:ACTED_IN]->(m)<-[:acted_in]-(coactors) return="" distinct="" coactors.name="" <="" td=""> MATCH {class: Person, as: tom, where: (name = 'Tom Hanks')}-ACTED_IN->{as: m}<-acted_in-{class: person,as:="" coactors}="" return="" coactors.name="" <="" td="">
Neo4j's Cypher OrientDB's MATCH
MATCH (people:Person)-[relatedTo]-(:Movie {title: "Cloud Atlas"}) RETURN people.name, Type(relatedTo), relatedTo MATCH {class: Person, as: people}--{as: m, where: (title = 'Cloud Atlas')} RETURN $pathElements

results matching ""

    No results matching ""