Fill every node in path with info from other nodes


In my database I have the following schema:



Each Client has a property called 'sector' that is a code referencing the Sector's node's own 'code' property.

Client {
name: "Client #1",
code: "CC1"
sector: "01"
Sector {
name: "Retail"
code: "01"

I need to query Clients by their code and ideally get the sector's info from within the Clients response.

I'm trying with this query which is only slightly different from what Spring Data Neo4j runs when calling findByCode() :

MATCH (n:`Client`) 
WHERE n.code = "CC1" 
MATCH (sec:Sector {code:n.sector})
RETURN n{.id, .code, .name, sector:sec,  __nodeLabels__: labels(n), __internalNeo4jId__: id(n), __paths__: [p = (n)-[:`LINK`]->()-[:`LINK`*0..]-() | p]}

Expected behavior:
Get all nodes with sector property filled with the Sector data that matches the clients' sector property.

Actual behavior:
Only the first node from the result has sector filled.

I know the query is wrong and I should apply the same MATCH (s:Sector {code:n.sector})) clause to nodes(p) from the path but I don't know how.


Can you design your model on and post the picture of it here.

MATCH (n:Client)
MATCH (sec:Sector {code:n.sector})

Hi Gabriel, you can find an example of both nodes properties in the OP.
There aren't any relationship between them. Client nodes have a property 'sector' that is a Sector's code.

Ideally I don't want to have to change the schema.