Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-28-2018 11:21 AM
Im trying to get all the nodes that belong to ukcoastal in this image, so navarea 1 has messages that belong to it, uk coastal also has messages that belong to it, how do I get this back in the query im using
MATCH (message:NavareaMessage{active:true})-[r:BelongsTo]->(navarea:Navarea{id:1}) OPTIONAL MATCH (coastalzones)-[c:IsCoastalOf]->(navarea)
return message,navarea, coastalzones
thanks
12-28-2018 11:24 AM
It's hard to tell what your true inputs and outputs are supposed to be (this looks like just a hardcoded example). Which nodes are your real starting nodes, and which nodes are unknown (besides the connected messages)?
Also, do you want any grouping in your returned data? You can use collect()
to aggregate nodes.
An example of desired output would help us understand what you want.
12-28-2018 11:30 AM
I have hardcoded it to navarea 1 that has id 1. im pretty much looking for this in the image
12-28-2018 11:33 AM
So is your interest the graphical results view only in the browser, or are you expecting some desired textual output format?
12-28-2018 11:39 AM
for now just graphical, im only modelling it all out now
12-28-2018 12:31 PM
Oh, in that case this should work:
MATCH path = (:NavareaMessage{active:true})-[:BelongsTo]->()-[:IsCoastalOf*0..1]->(:Navarea{id:1})
RETURN path
We have our starting node, and we're interested in the active messages that :BelongsTo both the starting node and potentially other nodes that could be connected by an :IsCoastalOf relationship (the *0..1 treats this as an optional expansion).
12-28-2018 02:52 PM
ok thanks, that works really well visually, and when I expand it to not just navarea 1 I can see how its all laid out. Ill have a toy around and see what I can do from it, ill start thinking about how the data is returned and how I can format it so I can consume the data better from my external app. one more point, ive set the data out so it goes from bottom up eg message belongs to navarea, is there any difference from doing navarea contains message?
12-28-2018 03:08 PM
There's no difference performance-wise, just whatever makes the most sense to you.
12-28-2018 03:25 PM
yeah I was aware performance wise its the same, but how about the format of the data coming back? I can see from the results table every row has a navarea and its details, so that's lots of duplicate data coming back, which is fine for the visual, if for every row in the results I get a Navarea, properties eg list of messages and a list of coastalzone that has a property that's a list of messages etc, is it purely the query that affects that or is how I lay out the data important?
All the sessions of the conference are now available online