Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-26-2019 06:47 AM
Hi all,
I am looking to get a Shortest path query that will get from one node label (:Person) to an company (:Organisation), this has to happen via multiple relationship types e.g (:Person)-[:Knows]-(:Person)-[:Colleague]-(:Person)-[:Works_For]-(:Organisation).
The dilema I face is that the [c:Colleague] relationship has properties such as c.Strength, where strenght can be weak, casual or strong. I would like my query to take this into account and only display the [c:Colleague] relationship that has the strong strength property. Also as a bonus id like the query to take in more relationship types such as [f:Friends] (Note:friends has the same strenght property).
Many thanks,
Sam.
07-26-2019 11:10 AM
Add the selected property value to the relationship:
(:Person)-[:Knows]-(:Person)-[:Colleague {Strength: "strong"}]-(:Person)-[:Works_For]-(:Organisation)
07-29-2019 03:05 AM
Hi,
Can you help me with the cypher for that,
I have tried the following but i get an error saying that you can only have one relationship type.
MATCH (c:Company{Name:"Aviation International"}),(p:Person{Name:"Sean Callaghan"}), (cc:Company),
p= shortestPath ((p)-[*]-(c)-[:Works_For{Strenght:"Strong"}]-(cc))
return p
Kind regards,
Sam.
07-29-2019 05:02 AM
Yeah @skirwan
First of all there is a tiny mistake in your query, you have used variable p multiple times .
Second yes you can do this. in shortest path you are giving multiple relationships. so do one thing just mentioned source node and terminal node that is Person and Company. and before that you just give a match that will have (c)-[:Works_For{Strenght:"Strong"}]-(cc)
hope so it works for you
07-29-2019 07:16 AM
Thanks for the reply, I think I have it resolved.
Kind Regards,
Sam.
All the sessions of the conference are now available online