How can I optimize this cypher query? It's 3-4 times slower than a similar query using Gremlin.
START movie=node:vertices(movieId="100")
MATCH genera1<--movie<--()-[ratedRel:rated]->anotherMovie-->genera1
WHERE ratedRel.stars > 3
RETURN anotherMovie.title as title, anotherMovie.movieId as id,
genera1.genera as genera,
COUNT(anotherMovie) as count ORDER BY count(anotherMovie) DESC LIMIT 20;
I'm just trying to retrieve movies that have been rated with more than 3 stars and that have the same genera as the START node: http://markorodriguez.files.wordpress.com/2011/09/movielens-schema.png?w=350
I'm running the query in the console and I'm using Neo4j 1.9
The Gremlin query:
m = [:];
x = [] as Set;
v = g.v(node_id);
v.out('hasGenera').aggregate(x).back(2).inE('rated').
filter{it.getProperty('stars') > 3}.outV.outE('rated').
filter{it.getProperty('stars') > 3}.
inV.filter{it != v}.
filter{it.out('hasGenera').toSet().equals(x)}.
groupCount(m){\"${it.id}:${it.title.replaceAll(',',' ')}\"}.iterate();
m.sort{a,b -> b.value <=> a.value}[0..24];