Hello,
I am playing around with the plugin system of neo4j.
I just want to call my function with an ID and want the neighbours of this node returned as a String:
public class Neighbours {
@Context
public GraphDatabaseService db;
@UserFunction
public String neighbours(@Name("nodeId") long nodeId) {
Node node = db.findNode(Label.label(""), "id", nodeId);
return StreamSupport.stream(node.getRelationships().spliterator(), false)
.map(neighbourNode -> neighbourNode.getProperty("id").toString())
.collect(Collectors.joining(", "));
}
}
Calling my function causes this error:
Neo.ClientError.Procedure.ProcedureCallFailed
Failed to invoke function `example.neighbours`: Caused by: java.lang.NoSuchMethodError: org.neo4j.graphdb.GraphDatabaseService.findNode(Lorg/neo4j/graphdb/Label;Ljava/lang/String;Ljava/lang/Object;)Lorg/neo4j/graphdb/Node;
I also tried other methods of GraphDatabaseService, no luck.
What is wrong with my function? I am using neo4j-community-4.0.4.
Also I do not have any labels on my nodes. Would my above implementation work to retrive my label-less nodes or do I have to use null
as parameter?
//edit: ok, seems like the procedure-template on github ist for neo4j 3.x and I am using 4.x.
Is there any documentation on how to do this in the newer Neo4j?