Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-19-2020 06:22 AM
So given a query like the following:
MATCH (x:A {custom_id:0})-[r]-(y:B)-[:SUBTYPE]->(z:B { name: "Zed"}) RETURN x,r,y
I would like the graph to return literally:
x
y
x
and y
however I also get the relationships between all the y
s which in my case tend to be many. Is it not possible to filter those edges out somehow?
05-19-2020 07:50 AM
Hello,
Something like this should do the trick:
MATCH (x:A)-[r]-(y:B)-[:SUBTYPE]->(z:B {name:"Zed"}) RETURN x, collect(r)
x
: the node x
collect(r)
: all the relationships between x
and y
If you want the list of x
, you can collect them:)
I hope it helps:)
05-19-2020 07:57 AM
It does not work, more specifically:
... RETURN x, collect(r)
then I only get the x and edges it has with itself.... RETURN x, collect(r), y
then I get the same as OP05-19-2020 08:05 AM
What you want to return is ambiguous:
x
?y
, so you want the list of x
nodes?x
and y
, so you want the list of r
or all the path (x-a-y)?05-19-2020 08:35 AM
I see, my bad, in my efforts to simply and make it abstract I must have missed some details. Let me clarify:
x
(i will update the OP)05-19-2020 08:39 AM
Ok, so something like this should be better:
MATCH p=(x:A)-[r]-(y:B)
WHERE (y)-[:SUBTYPE]->(z:B {name:"Zed"})
RETURN p
05-19-2020 11:44 PM
I am getting the same output. I cant really post a screenshot but essentially I am matching one node for x
and three nodes for y
(let's call them y1, y2, y3). With these nodes, I would like to get the edges (x-y1), (x-y2), and (x-y3), but none of the (y1-y2), (y1-y3) and (y2-y3). Is that possible?
Also what is the difference between:
MATCH p=(x:A {custom_id:0})-[r]-(y:B)
WHERE (y)-[:SUBTYPE]->(z:B {name:"Zed"})
RETURN p
and
MATCH (x:A {custom_id:0})-[r]-(y:B)-[:SUBTYPE]->(z:B {name: "Zed"}) RETURN x,r,y
05-20-2020 12:56 AM
Hi @ukirik,
Welcome to the community..
In your query you have not specified the direction of r. Also I hope there is only one type of relationship between A and B
05-20-2020 12:59 AM
There isn't one but rather multiple different types of relationships we capture in the graph between nodes of type A
and type B
, all equally interesting in this case. The directionality is important for the for the SUBTYPE
relationship between the nodes of type B
05-20-2020 01:02 AM
In that case you will definitely get high number of nodes of Label B. If you are available we can discuss on skype.
Also have a look into
https://neo4j.com/docs/cypher-manual/current/introduction/uniqueness/?_ga=2.111950348.923754055.1589...
04-11-2021 12:59 PM
I am having the same issues, I think, though in an even simpler form.
I have a relation named :OWNS and lets call the other relation :CUSTOMER and a relation named :PARTNER
And I have nodes with types (Individual:Party) and (:Organization:Party)
And I try to return the parties that own an item.
MATCH (p:Party)-[r:OWNS]->(i:Item) RETURN p, r, i
And my general understanding is that this then would return the graph with the matching elements. But I am getting other elements as well. I am getting all other nodes and relations from nodes that match the query. So if a party got an :OWNS relation then all other relations and the linked nodes that is linked to that party shows.
THough in the table mode it seems to only list the real data. Is there a configuration in neo to not print links from matched nodes unless asked for???
07-23-2021 06:41 AM
In the neo4j browser view, this may be the reason for seeing non-explicitly queried edges:
TLDR: The neo4j browser by default auto-completes to show all relationships that exist between nodes in the query/visualisation. This can be turned off in the settings tab (click on the gear bottom left) by unselecting "Connect result nodes".
All the sessions of the conference are now available online