cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

apoc.refactor.mergeNodes singleElementAsArray config property ignored

Hi all,

Looking at the documentation for mergeNodes it seems that properties that are merged to create a single element array can be coerced into an atomic value (the default), or kept as a single-element array if the singleElementAsArray config is set to true (see "config properties" table on referenced page).

When attempting to merge nodes in a very simple graph:

merge (:ToMerge {prop1: ['single array'], prop2: 'atom'})
merge (:ToMerge {prop1: ['single array'], prop2: 'alone'})

... using the cypher:

match (n1:ToMerge {prop2: 'atom'})
match (n2:ToMerge {prop2: 'alone'})
with [n1, n2] as nodes
call apoc.refactor.mergeNodes(nodes, {properties: "combine", singleElementAsArray: true}) yield node
return node

A single merged node results (as expected); on this node prop2 is ['atom', 'alone'] (also as expected) but prop1 is 'single array' rather than ['single array'] as I expected (the single element array is converted to an atomic value).

I'm not sure if this is a user error or a documentation issue; any help appreciated.

3 REPLIES 3

conker84
Graph Voyager

@neo4j11 what apoc version are you using?

I've tried it with 4.2.0.0-all, and with a 4.0 version and it appears not to work in either.
4.2 version can be tested using dockerised neo:

docker run -p7474:7474 -p7687:7687 -e NEO4J_AUTH=neo4j/neo4k -e NEO4JLABS_PLUGINS=\[\"apoc\"\] neo4j

then running the cypher from the comment above

conker84
Graph Voyager

@neo4j11 the feature is not yet released, the docs are updated automatically by a process but they should not show that feature at this time sorry for the mistake.
I'll talk to the team to plan a new release ASAP but if you want in the meanwhile you can build it from the source.
Thank you so much!
Andrea