Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-20-2022 09:06 AM
(class:CLASS {names: ['sam','John',amal','greg','sam','nabil','greg',John',sam'])
in my graph, I have a node called class. one of its properties is a list property called names.
I am trying to traverse all nodes of class and replace all occurrences of a word with another new word. the name list might have one or more occurrences of the same word.
need your help 🙂
11-20-2022 02:46 PM
Do you have a specific mapping of the existing values to the new values? Do you want to remove the duplicates?
you should use some of the functions in the apoc collections group to simplify your tasks.
https://neo4j.com/labs/apoc/4.4/overview/#_apoc_coll
I can help with a specific query if you answer the questions and provide the mappings.
11-21-2022 04:23 AM
Thank you
the problem is simple but I am stuck
I am in data cleansing phase
there will be an input list “inList” of strings (unique items and no duplicates), I need to search this inList string against a property called “names” in every CLASS node. Whenever a match of any item in the inList with any item in names, the item in names should be replaced with two items which are the first letter and the rest of the item.
inList[“Ali”, “Sam”,”Ali”]
(node:CLASS {names:[“Sam”,”Nour”,”Danny”,”Ali”, “Sally”, “Ali”]})
the outcome after update should look like:
node:CLASS {names:[“S”,”am”,”Nour”,”Danny”,”A”,”li”, “Sally”, “A”,”li”]})
the number two f nodes is more than 14,000
the names list is variable in length and the
11-21-2022 08:03 AM
You stated the inList will not include duplicates, but your example does. I assume that is an error. Does the solution need to retain the original order of the names list?
11-21-2022 09:02 AM
you are right, I made a mistake in inList. it should not have duplicates. and yes, the solution should retain the original order in the list. just replace the found item with its first character and the rest of the item.
All the sessions of the conference are now available online