Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-04-2022 11:51 AM
I have two different types of nodes that I load from a dataset. these nodes have the same id values with different names. how can i relate between them using these same id values. I tried the following two separate codes, but there is no change. can you help?
match (movie:Movie {id:movie.movieId}), (movieGenres:MovieGenres {id:movieGenres.movieGenresId})
create (movie) - [:GENRE] -> (movieGenres)
match (movie:Movie where id(movie)=toInteger(movie.movieId))
match (movieGenres:MovieGenres where id(movieGenres)=toInteger(movieGenres.movieGenresId) )
merge (movie) - [:GENRE] -> (movieGenres)
Solved! Go to Solution.
08-04-2022 12:41 PM - edited 08-04-2022 12:42 PM
This query should work normally
MATCH (m:Movie)
MATCH (g:MovieGenres)
WHERE toInteger(m.movieId) = toInteger(g.moviesGenresId)
MERGE (m)-[:GENRE]->(g)
08-04-2022 12:21 PM - edited 08-04-2022 12:22 PM
Hello @gusto 😊
The id() function returns the Neo4j internal ID of node/relationship.
This query should do what you want:
MATCH (m:Movie)
MATCH (g:MovieGenres)
WHERE m.movieId = g.movieGenresId
MERGE (m)-[:GENRE]->(g)
Regards,
Cobra
08-04-2022 12:30 PM
hi @Cobra cobra, thanks for your reply.
But when I try with the code you showed, there is no change.
I want to connect different nodes with same id's.
thanks again.
08-04-2022 12:33 PM
Neo4j Internal ID are unique so it won't be possible by definition. Do you have common ids between Movie and MovieGenres nodes?
Can you tell me all the properties you have for these two nodes and the type of this properties?
Can you share some queries to recreate your dataset?
08-04-2022 12:39 PM
As seen in the picture, movieID and moviesGenresId have the same value. I wanted to associate nodes using them. I don't know if such a thing is possible. is it possible? thanks.
08-04-2022 12:41 PM - edited 08-04-2022 12:42 PM
This query should work normally
MATCH (m:Movie)
MATCH (g:MovieGenres)
WHERE toInteger(m.movieId) = toInteger(g.moviesGenresId)
MERGE (m)-[:GENRE]->(g)
08-04-2022 12:43 PM
There was a typo in my query, the s was messing in moviesGenresId. You can try to also remove toInteger() functions.
08-04-2022 12:46 PM
Thank you very much it worked. I have one more problem. I have two separate node types movies_genres and directors_genres. but in one the name is visible on the nodes while the other is not. why could it be?
08-04-2022 12:50 PM
Thank you so much.
All the sessions of the conference are now available online