diff --git a/.gitignore b/.gitignore index b6e4761..e4e0ac0 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,5 @@ dmypy.json # Pyre type checker .pyre/ + +.idea \ No newline at end of file diff --git a/README.md b/README.md index f0ea1ab..f60c264 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,32 @@ -# neo4j-yelp +# Neo4j Yelp Dataset Solution + Contains Python scripts to import and model the Yelp challenge dataset into Neo4j respectively. + +## Getting Started + +### Step 1: + +Download the [Neo4j Community Edition](https://neo4j.com/download-thanks/?edition=community&release=4.0.1&flavour=unix) ZIP or tarball or start the Neo4j Docker container with the `docker-compose.yml` file. + +If using the ZIP or tarball, extract the archive to a directory e.g. `$HOME`: +``` +tar -xvzf neo4j-community-4.0.1-unix.tar.gz -C ~/. +``` + +### Step 2: + +If not using the Docker image, start Neo4j using the `neo4j` binary in the `neo4j-community-4.0.1/bin` file. Example: +``` +~/neo4j-community-4.0.1/bin/neo4j start +``` +Note this needs to run with Oracle Java 11 or OpenJDK 11. I recommend using [AdoptOpenJDK 11](https://adoptopenjdk.net/installation.html?variant=openjdk11&jvmVariant=hotspot) and setting $JAVA_HOME to the location of the directory e.g. `export JAVA_HOME=/home/david/Downloads/jdk-11.0.5+10`. + +Neo4j browser should now be running on `http://localhost:7474`. Default username and password is `neo4j` and `neo4j` respectively. + +### Step 3: + +Before running the `neo4j_yelp.py` script, make sure that you have installed all of the dependencies and edited `config.py` to contain your credentials. To download all the dependencies you can simply type: +``` +pip3 install -r requirements.txt --user +``` + diff --git a/config.py b/config.py index 5644dbd..8e45b4d 100644 --- a/config.py +++ b/config.py @@ -1,3 +1,5 @@ +PROTO = "bolt" USER = "neo4j" -PASSWORD = "bitnami" -URI = "bolt://localhost:7687" \ No newline at end of file +PASSWORD = "MyPassword" +HOSTNAME = "localhost" +PORT = "7687" diff --git a/neo4j_yelp.py b/neo4j_yelp.py index 1e585af..3398784 100644 --- a/neo4j_yelp.py +++ b/neo4j_yelp.py @@ -1,13 +1,8 @@ -from neo4j import GraphDatabase +from py2neo import Graph +import config -uri = "bolt://0.0.0.0:7687" -driver = GraphDatabase.driver(uri, auth=("neo4j", "bitnami")) +uri = "{}://{}:{}@{}:{}".format(config.PROTO, config.USER, config.PASSWORD, config.HOSTNAME, config.PORT) -def print_friends_of(tx, name): - for record in tx.run("MATCH (a:Person)-[:KNOWS]->(f) " - "WHERE a.name = {name} " - "RETURN f.name", name=name): - print(record["f.name"]) +graph = Graph(uri) -with driver.session() as session: - session.read_transaction(print_friends_of, "Alice") \ No newline at end of file +print(graph.evaluate("MATCH (tom {name: \"Tom Hanks\"}) RETURN tom")) diff --git a/requirements.txt b/requirements.txt index 3dfe2b6..26b0ce9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1 @@ -neo4j==1.7.6 -neobolt==1.7.16 -neotime==1.7.4 \ No newline at end of file +py2neo \ No newline at end of file