Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-16-2020 09:53 AM
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 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 *;
Solved! Go to Solution.
05-18-2020 09:56 AM
You can close this topic by accepting the message with the answer as answer and reopen a new one when you need it:)
05-16-2020 10:01 AM
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? 🙂
05-16-2020 12:55 PM
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
05-16-2020 11:14 AM
You can try WHERE r1.rating>1 and/or r2.rating>1
Thanks
05-16-2020 12:59 PM
Hi, I tried it but still didn't work. Thank you for your prompt reply, it is greatly appreciated.
05-16-2020 01:05 PM
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
05-16-2020 01:10 PM
Hi, I run it but i get the following error: (no changes, no records)
05-16-2020 01:12 PM
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
05-16-2020 01:17 PM
Hi, I get null on both averages
u1_average | u2_average |
---|---|
null | null |
05-16-2020 01:18 PM
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 *
05-16-2020 02:53 PM
Hi, this also gets me an error code: (no changes, no records)
05-16-2020 02:56 PM
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:)
05-17-2020 03:16 AM
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 |
05-17-2020 12:01 AM
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!!
05-17-2020 02:38 AM
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.
05-17-2020 02:40 AM
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 |
05-17-2020 02:41 AM
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)
05-17-2020 03:35 AM
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:)
05-17-2020 11:07 PM
Hi, it gave me the following
Neo.ClientError.Statement.SyntaxError: Variable u1
not defined (line 1, column 16 (offset: 15))
05-18-2020 02:07 AM
Yeah, my bad, I updated my last post, it should work:)
05-18-2020 07:21 AM
It exists! Thanks
Somehow i managed to graph it by finally writing the following code:
<>
MATCH (u1:User{name:"Angela Thompson"})
MATCH (u2:User{name:"Nicole Ramsey"})
MATCH (u1:User{name:"Angela Thompson"})-[:RATED]->(m1:Movie)-[:IN_GENRE]->(g:Genre{name:"Drama"})<-[:IN_GENRE]-(m2:Movie)<-[:RATED]-(u2:User{name:"Nicole Ramsey"})
RETURN *
05-18-2020 07:25 AM
Normally, you can do that:
MATCH (u1:User{name:"Angela Thompson"})
MATCH (u2:User{name:"Nicole Ramsey"})
MATCH (u1)-[:RATED]->(m1:Movie)-[:IN_GENRE]->(g:Genre{name:"Drama"})<-[:IN_GENRE]-(m2:Movie)<-[:RATED]-(u2)
RETURN *
Nice, so you can check if there are ratings > 1 on relationships:)
05-18-2020 09:01 AM
YES! It works and the code is shorter, fantastic! Thank you so much.
05-18-2020 09:03 AM
Do you need help for anything else?
05-18-2020 09:55 AM
As soon as it pops up THX!!
05-18-2020 09:56 AM
You can close this topic by accepting the message with the answer as answer and reopen a new one when you need it:)
All the sessions of the conference are now available online