Neo4j Cypher :: Nested Query :: Update a node with max() value from another query

16 views
Skip to first unread message

Ajay Krishnamurthy

unread,
Nov 14, 2016, 10:34:07 AM11/14/16
to Neo4j
I am in need to update the PersonalData object with the maximum of sensitivity value of its PersonalDataItems.
Below query throwing the error : Invalid input 'R': expected whitespace,[near RETUTN MAX(personalDataItem.sensitivity) AS mxVal] 

Please help me to resolve this ..

QUERY : 

WITH personalDatas = (PersonalData) -[:USED_ON]-> (resource:Resource) <-[:OWNS]-(org:Organisation {organisationId : 'XXX-YYYY-ZZZ'} ) 
UNWIND  personalDatas AS personalData 
SET personalData.sensitivity = 
(WITH(personalDataItem : PersonalDataItem) <-[r:CONTAINS_DATA_ITEM]- (pd : PersonalData {id: ID(personalData)})  RETUTN MAX(personalDataItem.sensitivity) AS mxVal)

Thanks & Regards
Ajay


Michael Hunger

unread,
Nov 14, 2016, 10:40:50 AM11/14/16
to ne...@googlegroups.com
This doesn't really make sense, did you read through the Cypher online training?

you probably mean something like

MATCH (personalData:PersonalData) -[:USED_ON]-> (resource:Resource) <-[:OWNS]-(org:Organisation {organisationId : 'XXX-YYYY-ZZZ'} ) 
MATCH (personalDataItem : PersonalDataItem) <-[:CONTAINS_DATA_ITEM]- (personalData)
WITH personalData, max(personalDataItem.sensitivity) as maxSensitivity
SET personalData.sensitivity = maxSensitivity

or in one single MATCH pattern

MATCH(personalDataItem : PersonalDataItem) <-[:CONTAINS_DATA_ITEM]-(personalData:PersonalData) -[:USED_ON]-> (resource:Resource) <-[:OWNS]-(org:Organisation {organisationId : 'XXX-YYYY-ZZZ'} ) 
WITH personalData, max(personalDataItem.sensitivity) as maxSensitivity
SET personalData.sensitivity = maxSensitivity



--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages