Here i am having confusion,
this is my Scala code in which i am integrating neo4j and this is how i am creating nodes and relationships.
df.select("easy_id","device_name_first").distinct().write
.mode("Overwrite")
.format("org.neo4j.spark.DataSource")
.option("relationship", "HAS_DEVICE")
.option("relationship.save.strategy", "keys")
.option("relationship.source.save.mode", "Overwrite")
.option("relationship.source.labels", ":EasyID")
.option("relationship.source.node.properties", "easy_id:id")
.option("relationship.source.node.keys", "easy_id:id")
.option("relationship.target.save.mode", "Overwrite")
.option("relationship.target.labels", ":device_name_first")
.option("relationship.target.node.properties", "device_name_first:DeviceName")
.option("relationship.target.node.keys", "device_name_first:DeviceName")
when i am returning nodes and their relationships
this is what i am getting, combined relationships.
My understanding: Relationships of both of the nodes should be separate.
When I expand a node(node A), it shows all its relationships as expected, but it also displays relationships of another node(node B) that I haven’t expanded yet. Additionally, some of Node A’s relationships appear combined, while others are shown separately.
Is this a really weird behaviour? If no then please explain.
Any help would be really Appreciated!
There're no "node A" or "node B" in your diagram - so hard to follow.
These two nodes are EasyID's i.e, 32599251 and 4956155..
node A and node B were just example.
@joshcornejo
You're doing the equivalent of an RDBMS:
SELECT * FROM X WHERE CONDITIONS
That's why you are retrieving A & B.
Yes - that's a "give me everything" query, there's no "WHERE" condition if you only want 32599251.
These are the steps i am following. I am asking why are these relationships are connected with the another node also?
Because i have written the code to create nodes and relationships separately. (This code i have sent above is just an example of how i am creating).
@joshcornejo
Your
match (n) return n limit 1
is returning the first node it finds. When you change to limit 2
it now gives you the first 2 it finds.
you are still doing the equivalent of a SELECT *
The Neo4j Browser has an intrinsic behavior that finds and displays (in the visual graph results only) all relationships found between nodes you are returning. It performs this as a separate query under-the-hood before displaying the visual results, and this is why you are seeing relationships you did not expand and did not query for.
You can toggle this behavior in the Neo4j Browser settings.
Open up the settings panel (gear icon on the lower-left) and uncheck the Connect result nodes checkbox.
Now...if the above was not your actual issue (if it isn't an issue of unexpected visibility), and you don't expect both of those nodes to have relationships to the same common set of nodes, then either there is a misunderstanding about how your create code works, or there is a mistake in the create code itself that resulted in this.
You're not using Cypher here it looks like...can you give more information about what tools you are using to create your code? You may want to more closely review its documentation.
Provided this is still being converted to and executed as Cypher, you could check the query.log to find the queries that were actually executed to create your data.
I am creating a Spark job in which my aim is to insert data into the Neo4j. Language I am using is Scala.
@andrew_bowman