I'm looking for the best way to make a some kind of multiple JOIN in my cypher query. I find a solution, but it seems little bit too complex for me. The goal of this query, is by starting from a first node, to retrieve the id and a 'name' property from many other nodes related to the first one by relationships of many types (cf. below)
START c=node(72)
OPTIONAL MATCH (c)<-[:MANAGEMENT_TEAM]-(from_board)
OPTIONAL MATCH (c)<-[:SHAREHOLDER]-(shareholder)
OPTIONAL MATCH (c)-[:PRODUCT_OFFERED]->(product)
OPTIONAL MATCH (c)<-[:CUSTOMER]-(customer)-[:CORE_BUSINESS]->(industry_sector)
OPTIONAL MATCH (c)-[:ASSIGNEE]->(patent)
RETURN [x IN collect(DISTINCT(from_board))| {id:id(x), name:x.name}] AS Management,
[x IN collect(DISTINCT(shareholder))| {id:id(x), name:x.name}] AS Shareholders,
[x IN collect(DISTINCT(product))| {id:id(x), name:x.name}] AS Products,
[x IN collect(DISTINCT(customer))| {id:id(x), name:x.name}] AS Customers,
[x IN collect(DISTINCT(industry_sector))| {id:id(x), name:x.name}] AS Industry_sectors,
[x IN collect(DISTINCT(patent))| {id:id(x), name:x.name}] AS Patent
This query returns 6 columns, each of it contains a list of tuple (id & name). Do you see how improve it ? (especially the ugly part "extract/collect/distinct") Or, do you know another manner to do that ? Thanks