我正在尝试将Url-String转换为带有密码的节点:
`https://e.whoopidoo.nl/x/plugin/?pName=edit_data&MIDRID=S7Y1Mv2fa2tobGz5P8fW0NzU4n8RUMjYwNIAAAA21&Z=-394462905&utm_source=DMdelivery&utm_medium=email&utm_content=ae9982saa&utm_campaign=aletter%202018"`
并使用
将其转换为数组`split(apoc.data.url(u.url).query,"&") as urlArr`
结果数组:["pName=edit_data", "MIDRID=S7Y1Mv2fa2tobGz5P8fW0NzU4n_RrZGhsZmRJQAA67", "Z=-1006289928", "utm_source=DMdelivery", "utm_medium=email", "utm_content=ae9982saa", "utm_campaign=aletter 2018"]
请帮助您采取以下步骤:
urlArr
或UNWIND
或FOREACH
遍历apoc.function
?split( arrValue, "=") as keyValue
中使用每个值(:urlQuery{ collectedKeyVals })
密码:
MATCH (u:Url)
WITH u, split(apoc.data.url(u.url).query,"&") as urlArr
// UNWIND or FOREACH - urlArr?
// ... in loop ... split( arrValue, "=") as keyValue
// How to COLLECT efficiently ?
// MERGE or CREATE
答案 0 :(得分:0)
List comprehension
获取键值对列表apoc.map.fromPairs
函数从具有键值对的列表中获取地图SET
从地图上设置属性WITH "https://e.whoopidoo.nl/x/plugin/?pName=edit_data&MIDRID=S7Y1Mv2fa2tobGz5P8fW0NzU4n8RUMjYwNIAAAA21&Z=-394462905&utm_source=DMdelivery&utm_medium=email&utm_content=ae9982saa&utm_campaign=aletter%202018" as url
WITH split(apoc.data.url(url).query,"&") as urlArr
// 1
WITH [n in urlArr | split(n, '=')] as keyValuePairs
// 2
WITH apoc.map.fromPairs(keyValuePairs) as keyValueMaps
// 3
CREATE (U:urlQuery) SET U = keyValueMaps
RETURN U
答案 1 :(得分:0)
您可以在创建节点后使用UNWIND
来通过apoc动态设置这些属性。
WITH split(apoc.data.url("https://e.whoopidoo.nl/x/plugin/?pName=edit_data&MIDRID=S7Y1Mv2fa2tobGz5P8fW0NzU4n8RUMjYwNIAAAA21&Z=-394462905&utm_source=DMdelivery&utm_medium=email&utm_content=ae9982saa&utm_campaign=aletter%202018").query,"&") as urlArr
CREATE (N:urlQuery)
WITH N,urlArr
UNWIND urlArr as urlValue
CALL apoc.create.setProperty(N, split( urlValue, "=")[0], split( urlValue, "=")[1]) YIELD node
RETURN node