Showing results forΒ 
Search instead forΒ 
Did you mean:Β 

Head's Up! Site migration is underway. Phase 2: migrate recent content

replacing an item in a list with a new one. the list is a property in a node

Node Link

(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 πŸ™‚



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.

I can help with a specific query if you answer the questions and provide the mappings.

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

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?

Node Link

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.