Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-08-2021 03:15 AM
Hello, I'm trying to do the below and was wondering if it was possible? I'd like to use the property value of a node as a key on another node to get it' value. I've seen how one sets params and then can use the dollar sign within square braces to get a property - but not sure how that would be done here. Thanks in advance
match (p:Product)-[:HAS_FIELD]->(field:FieldConfig)
with *, field.name as fieldName
where field.type = 'important'
return distinct p.name, p.productId,field.name,field.type, p[fieldName] limit 25
Solved! Go to Solution.
12-09-2021 08:06 AM
@joe5
Sorry if I not understand, but the provided query seems to work.
That is, if I have a dataset like: create (p:Product {test: 'another'})-[:HAS_FIELD]->(field:FieldConfig {name: 'test', type: 'important'})
,
the p[fieldName]
return 'another'
(in my example case).
Maybe you want to handle a SET
clause?
In this case you could use the APOC procedures, in particular the apoc.create.setProperty ,
for example you could set a property with key the value of FieldConfig.name
and value 'whatever'
:
MATCH (p:Product)-[:HAS_FIELD]->(field:FieldConfig)
WITH *, field.name as fieldName
CALL apoc.create.setProperty(p, fieldName, 'whatever') yield node
RETURN *
12-09-2021 08:06 AM
@joe5
Sorry if I not understand, but the provided query seems to work.
That is, if I have a dataset like: create (p:Product {test: 'another'})-[:HAS_FIELD]->(field:FieldConfig {name: 'test', type: 'important'})
,
the p[fieldName]
return 'another'
(in my example case).
Maybe you want to handle a SET
clause?
In this case you could use the APOC procedures, in particular the apoc.create.setProperty ,
for example you could set a property with key the value of FieldConfig.name
and value 'whatever'
:
MATCH (p:Product)-[:HAS_FIELD]->(field:FieldConfig)
WITH *, field.name as fieldName
CALL apoc.create.setProperty(p, fieldName, 'whatever') yield node
RETURN *
12-10-2021 01:19 AM
@giuseppe.villani you're 100% right, my data was just not correct for the node. Apologies, it does work - thank you for your help
All the sessions of the conference are now available online