ellaqezi / hanryu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Based on neo4j:4.2.0

Quickstart

  1. Build the image and start the neo4j container

    export TAG=`date +"%Y%m%d%H%M"`
    export PW= #insert password here
    export NEO4J_AUTH=neo4j/$PW
    docker build --no-cache --build-arg NEO4J_AUTH -t hanryu/tracker:$TAG .
    rm -R $(pwd)/data/{databases,dbms,transactions}
    docker run -p7474:7474 -p7687:7687 -v $(pwd)/import:/import -v $(pwd)/data:/data \
    -e NEO4J_AUTH=$NEO4J_AUTH --user=$(id -u):$(id -g) hanryu/tracker:$TAG &
    unset NEO4J_AUTH

    Run ctrl + C or docker stop $(docker ps | grep hanryu | cut -d" " -f1) to stop the container.

    If you've previously created the database i.e. in $(pwd)/data, remember to remove the subdirectories when changing passwords. The database will otherwise expect the password you used the first time you set it up.

Step-by-step

  1. Start the neo4j container

    export PW= #insert password here
    docker run -p7474:7474 -p7687:7687 -v $(pwd)/data:/import -e NEO4J_AUTH=neo4j/$PW neo4j

    See How-To: Run Neo4j in Docker

  2. Go to http://localhost:7474/browser/ on your favourite browser

  3. Load data and display (see cypher script)

    LOAD CSV WITH HEADERS FROM 'file:///Cast.csv' AS row
    UNWIND split(row.Role, ' / ') AS name
    MERGE (role:Role {title: row.Title
    ,                 role:  name
    ,                 actor: row.Actor
    })
    WITH role, row
    MATCH (title:Title {title: row.Title})
    MATCH (actor:Actor {actor: row.Actor})
    // Create relationships between actors, roles and titles
    MERGE (actor)-[:AS]->(role)
    MERGE (role)-[:IN]->(title)
      ON CREATE SET role.Role = row.Role;
    
    // Display
    MATCH p = ()-[]-()-[]-()
    RETURN p
      LIMIT 750
    
    // up to 6 deg of separation
    match p=(:Actor {Actor: 'Park Hyung-sik'})-[*1..6]-(:Title) return p

References

stackoverflow docker-neo4j

About

License:GNU General Public License v3.0


Languages

Language:Shell 85.9%Language:Dockerfile 14.1%