Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
on 01-27-2021 08:05 AM
Hi,
In my database I have the following schema:
(Client)-[r:LINK*0..5]->(Client)
(Sector)
Each Client has a property called 'sector' that is a code referencing the Sector's node's own 'code' property.
E.g.:
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.
Thanks
Can you design your model on arrows.app 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.