I created 1 node,j but the nodesCreated count is 0:

I ran the following query in Neo4j but the nodesCreated count is 0, even though the node was successfully created:

CALL apoc.create.nodes(["Person", "Actor"], [{name: "Tom Hanks"}]);

Here's the response I got:

{
  "query": {
    "text": "CALL apoc.create.nodes([\"Person\", \"Actor\"], [{name: \"Tom Hanks\"}]);",
    "parameters": {}
  },
  "queryType": "rw",
  "counters": {
    "_stats": {
      "nodesCreated": 0,
      "nodesDeleted": 0,
      "relationshipsCreated": 0,
      "relationshipsDeleted": 0,
      "propertiesSet": 0,
      "labelsAdded": 0,
      "labelsRemoved": 0,
      "indexesAdded": 0,
      "indexesRemoved": 0,
      "constraintsAdded": 0,
      "constraintsRemoved": 0
    },
    "_systemUpdates": 0
  },
  "updateStatistics": {
    "_stats": {
      "nodesCreated": 0,
      "nodesDeleted": 0,
      "relationshipsCreated": 0,
      "relationshipsDeleted": 0,
      "propertiesSet": 0,
      "labelsAdded": 0,
      "labelsRemoved": 0,
      "indexesAdded": 0,
      "indexesRemoved": 0,
      "constraintsAdded": 0,
      "constraintsRemoved": 0
    },
    "_systemUpdates": 0
  },
  "plan": false,
  "profile": false,
  "notifications": [],
  "server": {
    "address": "5b6f7887.databases.neo4j.io:7687",
    "agent": "Neo4j/5.5-aura",
    "protocolVersion": 5
  },
  "resultConsumedAfter": {
    "low": 20,
    "high": 0
  },
  "resultAvailableAfter": {
    "low": 13,
    "high": 0
  },
  "database": {
    "name": "neo4j"
  }
}

I have verified that the APOC library is installed and that the parameters are correct. The node was actually created, so why is the nodesCreated count still 0? Are there any other reasons why this might be happening, and how can I fix this?

Hi,

Question: Did the nodes exist beforehand and is there a constraint on the nodes?

If there is a prior node and constrain, then no node should be created and 0 would be correct.

Try with some nodes you know before hand do not exist to test your syntax and to see if the apoc library is functioning correctly.
Andy

Where is that output generated from? When I run that query, the node is created and the nodes returned.

Don’t use APOC fot that if you need stats, just run Cypher and you should see results.

Well, the procedure does have utility if you want to dynamically set the node's label(s). Otherwise, I agree with you. I tend to stick with native cypher, unless necessary.

1 Like

You can set label with MATCH (n:One) SET n:Two RETURN labels(n). Also, don’t be afraid to use separated queries. They saved my day a lot of times tbh.

What I learn after almost 6 years is stick to CYPHER and use APOC as little as you can :slight_smile:

That is true, but that is setting a label that is known. I was referring to setting a label based on a passed parameter.

I agree with you on staying with cypher.

node has been created after run, It may be because apoc created nodes are not counted in summary.

Ok, good luck in that case.

/cheers