问题描述:

Referencing these 2 stackoverflow questions:

  1. Delete old nodes and relationships with Cypher in Neo4j 1.9
  2. Deleting indexed nodes in Neo4j

I have a graph where a number of Nodes are incorrectly in Indexes. I think this happened because Nodes were deleted using Cypher or using the Delete button on the Webadmin console, without realising that this would NOT also delete the Node from any Indexes that it was in.

The result is that these Nodes are now being returned incorrectly for queries which use those Indexes for the start Nodes.

Is it possible to remove a Node from an Index using Cypher, REST API or the Webadmin console?

Or am I going to have to write some custom Java (I'm using embedded mode) which does something like:

Iterable<Node> offendingNodes;

Iterable<Index<Node>> allIndexes;

for(Node offendingNode : offendingNodes) {

for(Index<Node> index : allIndexes) {

index.remove(offendingNode);

}

}

// Now re-index offendingNodes correctly

网友答案:

You can delete nodes from indexes with REST like so:

DELETE http://[address]:[port]db/data/index/node/[indexname]/[nodeid]

REST API - Indexes

相关阅读:
Top