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.import.json constraint check error while importing json generated by apoc.export.json.all #4194

Closed
saurabhkumar opened this issue Sep 20, 2024 · 2 comments
Assignees

Comments

@saurabhkumar
Copy link

saurabhkumar commented Sep 20, 2024

Expected Behavior (Mandatory)

The json files exported using apoc.export.json.all should get imported using apoc.import.json

Actual Behavior (Mandatory)

The error related to constraint check is getting generated even though it should have been fixed as per the fix for the issue 2930

How to Reproduce the Problem

Environment:: docker
Image: neo4j- 5.23.0-community-bullseye image

Docker compose file:

services:
  graph_db:
    image: neo4j:5.23.0-community-bullseye
    ports:
      - "7474:7474"
      - "7687:7687"
    environment:
      NEO4J_AUTH: neo4j/your_passwd
      NEO4J_PLUGINS: '["bloom", "apoc"]'
      NEO4J_apoc_export_file_enabled: "true"
      NEO4J_apoc_import_file_enabled: "true"
      NEO4J_apoc_import_file_use__neo4j__config: "true"

    volumes:
      - ./data:/data
      - ./plugins:/plugins
      - ./import:/var/lib/neo4j/import

Steps

  1. Start the container using docker compose file
  2. Add the graph nodes and relations (no constraints included)
  3. In the browser, generate the json file using CALL apoc.export.json.all("jsonfile.json")
  4. Stop the container
  5. Remove the data in the volume (note: sudo might be required due to folder ownership)
  6. Start the container again
  7. Check (exec into the running container using command docker exec -it <container id> /bin/bash and then check the import folder) that the json file exported earlier is available in the import folder
  8. Try to import the json using CALL apoc.import.json("jsonfile.json")

Currently used versions

Versions

  • OS: Ubuntu 20.04
  • Neo4j: 5.23.0
  • Neo4j-Apoc: 5.23.0
@Lojjs
Copy link
Contributor

Lojjs commented Sep 30, 2024

@saurabhkumar Thanks for reporting. We will investigate further and come back to you.

Best regards Louise, Neo4j

@Lojjs Lojjs self-assigned this Sep 30, 2024
@gem-neo4j
Copy link
Contributor

Hi!

This isn't a bug, Unique constraints are required to be able to do importing as the error is saying. The linked bug was that this error would happen, and any constraint that was made (e.g an existence constraint) would be accepted, which was incorrect as the constraint must be a uniqueness one.

Unfortunately, the procedure has WRITE mode and not SCHEMA mode, so it is not possible for this behaviour to change. I do see that this is not properly documented, and will amend that :)

Just to be clear, a unique constraint is needed for every imported node/relationship label/type on the importing id. The error message will let you know when a constraint has been missed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants