Retrieve a graph (U—-M-—G—-M—U) with the movies that user Angela Thompson and Nicole Ramsey have rated and are related with drama

Neo4j Browser version: 3.2.20

Hi,
I've been trying to code the above relationship between two users from the MOVIE Lens database and it gives me the following error. Can someone help? I just registered with the community so I hope I did't do anything wrong already :slightly_smiling_face: Thx

CODE error message: "Neo.ClientError.Statement.SyntaxError: Invalid input 'H': expected 'i/I' (line 8, column 2 (offset: 389)) "WHERE r2.rating>1"

CYPHER CODE:
MATCH(u1:User{name:"Angela Thompson"})
MATCH(u2:User{name:"Nicole Ramsey"})
MATCH(u1)-[r1:RATED]->(m:Movie)-[:IN_GENRE]->(g:Genre{name:"Drama"})<-[:IN_GENRE]-(m:Movie)<-[r2:RATED]-(u2)
WITH u1, avg(r1.rating) AS u1_average
WITH u2, avg(r2.rating) AS u2_average
MATCH(u1)-[r1:RATED]->(m:Movie)-[:IN_GENRE]->(g:Genre{name:"Drama"})<-[:IN_GENRE]-(m:Movie)<-[r2:RATED]-(u2)
WHERE r1.rating>1
WHERE r2.rating>1
RETURN *;

Hello,

It's not possible to have two FROM clauses that follow each other, what is the aim of your cypher request, what do you want to return? :)

You can try WHERE r1.rating>1 and/or r2.rating>1

Thanks

Hi,

I want to return a graph of the two users that have the same interest in movies with drama genre and of course ratings>1

Hi, I tried it but still didn't work. Thank you for your prompt reply, it is greatly appreciated.

Okay, a cypher request like this should do the trick:

MATCH p=(u1:User{name:"Angela Thompson"})-[r1:RATED]->(m:Movie)-[:IN_GENRE]->(g:Genre{name:"Drama"})<-[:IN_GENRE]-(m:Movie)<-[r2:RATED]-(u2:User{name:"Nicole Ramsey"})
WITH p, avg(r1.rating) AS u1_average, avg(r2.rating) AS u2_average
WHERE u1_average > 1 AND u2_average > 1
RETURN p

Hi, I run it but i get the following error: (no changes, no records)

It means the result is empty, can you try this:

MATCH (u1:User{name:"Angela Thompson"})-[r1:RATED]->(m:Movie)-[:IN_GENRE]->(g:Genre{name:"Drama"})<-[:IN_GENRE]-(m:Movie)<-[r2:RATED]-(u2:User{name:"Nicole Ramsey"})
RETURN avg(r1.rating) AS u1_average, avg(r2.rating) AS u2_average

Hi, I get null on both averages

u1_average u2_average
null null

Try

MATCH (u1:User{name:"Angela Thompson"})-[r1:RATED]->(m:Movie)-[:IN_GENRE]->(g:Genre{name:"Drama"})<-[:IN_GENRE]-(m:Movie)<-[r2:RATED]-(u2:User{name:"Nicole Ramsey"})
RETURN r1.rating AS u1_average, r2.rating AS u2_average

and this please

MATCH (u1:User{name:"Angela Thompson"})-[r1:RATED]->(m:Movie)-[:IN_GENRE]->(g:Genre{name:"Drama"})<-[:IN_GENRE]-(m:Movie)<-[r2:RATED]-(u2:User{name:"Nicole Ramsey"})
RETURN *

Hi, this also gets me an error code: (no changes, no records)

It's not error, it just means there is no result:) So the cypher request is good but there is no result for this configuration:)

@elias.demetriou can send the data?? it is easier for me

The data is movie lens which is found on the Neo4j. Let me see if i can find it and send it to you. Thank you so much for your help!!

Here;s the website to download the database. The big one is 3GB but there are smaller version of 5MB and 1MB. I'm not really sure which is used on the web software.

Hi again, i'm a bit confused because in the software when i checked the database it's called Recommendations.

Version: 3.5.11
Edition: Enterprise
Name: recommendations.db
Size: 71.88 MiB
Information: :sysinfo
Query List: :queries

This is the version i'm currently running. Thought it would help to know. Thx

Neo4j Browser version: 3.2.20

Neo4j Server version: 3.5.11 (enterprise)

Thank you so much for your guidance! The database in the web based software is Recommendations:

Version: 3.5.11
Edition: Enterprise
Name: recommendations.db
Size: 71.88 MiB
Information: :sysinfo
Query List: :queries

You can check if it exists a link for this case:

RETURN EXISTS((:User{name:"Angela Thompson"})-[:RATED]->(:Movie)-[:IN_GENRE]->(:Genre{name:"Drama"})<-[:IN_GENRE]-(:Movie)<-[:RATED]-(:User{name:"Nicole Ramsey"}))

It should return True if this relation exists, False else:)

Hi, it gave me the following

Neo.ClientError.Statement.SyntaxError: Variable u1 not defined (line 1, column 16 (offset: 15))