neo4j-graph-examples / recommendations Goto Github PK
View Code? Open in Web Editor NEWNeo4j Graph Example Movies Recommendation
Home Page: https://sandbox.neo4j.com?usecase=recommendations
Neo4j Graph Example Movies Recommendation
Home Page: https://sandbox.neo4j.com?usecase=recommendations
Neo4j Developer Relations Team,
Thanks for making the Neo4j sandboxes available. I use the movie recommendation sandbox to introduce graph concepts to students who do not have a background in computing.
In using the sandbox,there is a minor issue with the actor and director nodes that you may be aware of, but I figured I would pass it along. Some of the actors and directors have two nodes - one with a space before their name, and some have a single node, but also have a space before their name. Possibly this is due to parsing the data on the commas and not trimming out the spaces.
For the students, I have them run a few queries to fix the issue. They may not be the most efficiently written, but are included below.
Thanks again for providing this resource!
Best,
Scott
// The following query merges actors who have two nodes,
// the one having a space at the start of their name is merged into the other.
MATCH (n:Actor)
WHERE n.name STARTS WITH " " = False
WITH n.name as aname, " "+n.name as paddedname
MATCH (n1:Actor {name: aname}), (n2:Actor {name: paddedname})
WITH [n1,n2] as ns
CALL apoc.refactor.mergeNodes(ns, {properties:'discard'}) YIELD node
RETURN node
// The following query should be run after the query above and removes
// the space at the start of actor names where there was only one node
// for that actor
MATCH (n:Actor)
WHERE n.name STARTS WITH " " = True
SET n.name = TRIM(n.name)
RETURN n
// The following query merges directors who have two nodes,
// the one having a space at the start of their name is merged into the other.
MATCH (n:Director)
WHERE n.name STARTS WITH " " = False
WITH n.name as aname, " "+n.name as paddedname
MATCH (n1:Director {name: aname}), (n2:Director {name: paddedname})
WITH [n1,n2] as ns
CALL apoc.refactor.mergeNodes(ns, {properties:'discard'}) YIELD node
RETURN node
// The following query should be run after the query above and removes
// the space at the start of director names where there was only one node
// for that director
MATCH (n:Director)
WHERE n.name STARTS WITH " " = True
SET n.name = TRIM(n.name)
RETURN n
About half of this browser guide relies on some similarity functions in GDS 1.x that have been updated for 2.x and will not work once 2.x rolls out onto Sandbox. So this browser guide needs some updating.
model image
possibly use apoc.meta.graph instead of db.schema
for the example image it would be nicer to have a movie with actors, genre, directors and a few (3-5) ratings, than just a ratings picture
Hi Sirs,
I am trying to build the recommendation database at local by loading the given dump file: recommendations-40.dump
, but get the Not a valid Neo4j archive
error (same error both on windows and ubuntu)
Besides, I also surveyed and tried the possible solution about the error Knowledge Base neo4j-admin load causes "Not a valid Neo4j archive", but is still got same error.
Is there another limitation about the dumped file? or Is there any idea or suggestion about this?
.\bin\neo4j-admin load --from data\recommendations-40.dump --database "recommendations" --force --verbose
docker run --interactive --tty --rm \
-p 7480:7474 -p 7680:7687 \
-v /home/$USER/development/data/neo4jdb-movie-bk/data:/data \
-v /home/$USER/development/data/neo4jdb-movie-bk/backups:/backups \
--user=$(id -u):$(id -g) \
neo4j:4.0.7 \
neo4j-admin load --from=/backups/recommendations-40.dump --database="neo4j" --force
docker run -d \
--name neo4jdb-movie-bk \
-v /home/$USER/development/data/neo4jdb-movie-bk/data:/data \
-v /home/$USER/development/data/neo4jdb-movie-bk/logs:/logs \
-v /home/$USER/development/data/neo4jdb-movie-bk/import:/var/lib/neo4j/import \
-v /home/$USER/development/data/neo4jdb-movie-bk/plugins:/plugins \
-v /home/$USER/development/data/neo4jdb-movie-bk/backups:/backups \
-p 7478:7474 -p 7678:7687 \
--user=$(id -u):$(id -g) \
--env NEO4J_AUTH=<xxxx/xxxxx> \
neo4j:4.0.7
The log is shown as below:
>>.\bin\neo4j-admin load --from data\recommendations-40.dump --database "recommendations" --force --verbose
org.neo4j.cli.CommandFailedException: Not a valid Neo4j archive: data\recommendations-40.dump
at org.neo4j.commandline.dbms.LoadCommand.load(LoadCommand.java:189)
at org.neo4j.commandline.dbms.LoadCommand.loadDump(LoadCommand.java:119)
at org.neo4j.commandline.dbms.LoadCommand.execute(LoadCommand.java:91)
at org.neo4j.cli.AbstractCommand.call(AbstractCommand.java:59)
at org.neo4j.cli.AbstractCommand.call(AbstractCommand.java:29)
at picocli.CommandLine.executeUserObject(CommandLine.java:1743)
at picocli.CommandLine.access$900(CommandLine.java:145)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2101)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2068)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:1935)
at picocli.CommandLine.execute(CommandLine.java:1864)
at org.neo4j.cli.AdminTool.execute(AdminTool.java:77)
at org.neo4j.cli.AdminTool.main(AdminTool.java:58)
Caused by: org.neo4j.dbms.archive.IncorrectFormat: data\recommendations-40.dump
at org.neo4j.dbms.archive.Loader.openArchiveIn(Loader.java:191)
at org.neo4j.dbms.archive.Loader.load(Loader.java:74)
at org.neo4j.commandline.dbms.LoadCommand.load(LoadCommand.java:165)
... 12 more
Caused by: java.io.IOException: Decompression error: Unknown frame descriptor
at com.github.luben.zstd.ZstdInputStream.readInternal(ZstdInputStream.java:147)
at com.github.luben.zstd.ZstdInputStream.read(ZstdInputStream.java:107)
at java.base/java.io.FilterInputStream.read(FilterInputStream.java:107)
at org.neo4j.dbms.archive.CompressionFormat$2.decompress(CompressionFormat.java:79)
at org.neo4j.dbms.archive.CompressionFormat.decompress(CompressionFormat.java:148)
at org.neo4j.dbms.archive.CompressionFormat.decompress(CompressionFormat.java:125)
at org.neo4j.dbms.archive.Loader.openArchiveIn(Loader.java:175)
... 14 more
Suppressed: java.util.zip.ZipException: Not in GZIP format
at java.base/java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:166)
at java.base/java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:80)
at java.base/java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:92)
at org.neo4j.dbms.archive.CompressionFormat$1.decompress(CompressionFormat.java:52)
at org.neo4j.dbms.archive.CompressionFormat.decompress(CompressionFormat.java:148)
at org.neo4j.dbms.archive.CompressionFormat.decompress(CompressionFormat.java:132)
... 15 more
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.