Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apoc.refactor.mergeNodes gives IndexEntryConflictException on merge based on the same property #3405

Closed
frerikandriessen opened this issue Jan 13, 2023 · 2 comments
Labels
core-functionality Adding new procedure, function or signature to APOC core

Comments

@frerikandriessen
Copy link

Expected Behavior (Mandatory)

I want to merge two nodes with different labels (for example A and B) based on a property (for example prop1) that is equal for both of them.
See this example:

CREATE CONSTRAINT ON (a:A) ASSERT a.prop1 IS UNIQUE;
CREATE CONSTRAINT ON (a:B) ASSERT a.prop1 IS UNIQUE;
CREATE (a:A) SET a.prop1 = 1;
CREATE (b:B) SET b.prop1 = 1;

MATCH (a:A {prop1:1})
MATCH (b:B {prop1:1})
CALL apoc.refactor.mergeNodes([a, b]) YIELD node RETURN node;

This should merge the properties of both nodes together, without concern for the uniqueness constraint because the endresult is still one node with this specific prop1 value.

Actual Behavior (Mandatory)

Unfortunately, this gives an error like

Neo.ClientError.Procedure.ProcedureCallFailed: Failed to invoke procedure `apoc.refactor.mergeNodes`: Caused by: IndexEntryConflictException{propertyValues=( Long(1) ), addedNodeId=-1, existingNodeId=56096980}

How to Reproduce the Problem

See the example above

Currently used versions

Versions

  • Neo4j: 4.3.2
  • Neo4j-Apoc: 4.3.2

The problem is very similar to #762, but in this case the property with the constraint is the same for both labels.

This leads me to believe we might be doing something that is not supported/not the intended use. If so, why is this a bad idea/what should we look into?
Currently the only way we see around it is temporarily dropping the uniqueness constraint and adding it again after merging.

@nadja-muller nadja-muller added the core-functionality Adding new procedure, function or signature to APOC core label Jan 13, 2023
@nadja-muller
Copy link
Contributor

Hi. Thank you for reporting this. On a first glance this seems like a bug to me. We will look into it and come back to you.

@jexp jexp moved this to Todo in APOC Extended Larus Jan 19, 2023
@vga91 vga91 moved this from Todo to Core issues in APOC Extended Larus Jan 24, 2023
@vga91
Copy link
Collaborator

vga91 commented Aug 24, 2023

Fixed here: neo4j/apoc#361 (5.x) and #3598 (4.4)

@vga91 vga91 closed this as completed Aug 24, 2023
@github-project-automation github-project-automation bot moved this from Core issues with trello core card to Done in APOC Extended Larus Aug 24, 2023
@vga91 vga91 moved this from Done to Cherry-picked in APOC Extended Larus May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-functionality Adding new procedure, function or signature to APOC core
Projects
Development

No branches or pull requests

3 participants