Developer Guides Getting Started Getting Started What is a Graph Database? Intro to Graph DBs Video Series Concepts: RDBMS to Graph Concepts: NoSQL to Graph Getting Started Resources Neo4j Graph Platform Graph Platform Overview Neo4j Desktop Intro Neo4j Browser Intro… Read more →

Developer Guides

Want to Speak? Get $ back.

Procedures and Functions

User-Defined Procedures and Functions

User Defined Procedures and Functions are available within Cypher and encapsulate dedicated functionality.

Just by annotating methods of a Java class and deploying the resulting jar file into your Neo4j installation, you can make new functionality easily available within the query language.

To implement your procedures or functions you would use the Neo4j Embedded Java API. Besides an object-oriented API to the graph database, working with Node, Relationship, and Path objects, it also offers highly customizable, high-speed traversal- and graph-algorithm implementations.

We don’t provide code examples for the Java API on this page, because they are covered in detail in the Java developers manual.

Neo4j uses that functionality itself for built-in procedures for meta-data, cluster-, query- and user-management and more.

Several libraries already provide new capabilities using procedures and functions, here is an example from the APOC library.

MATCH (start:City {name: 'Berlin'}),(end:City {name: 'Malmö'})
CALL apoc.algo.dikjstra(start, end, "ROUTE","distance") yield path, weight
RETURN path
ORDER BY weight ASC LIMIT 10

To get you started we provided a template project and documentation in the Java developer manual.

More useful examples for user defined procedures can be found in our procedure & function gallery.