Neo4j icon

Neo4j

Work with Neo4j database

Overview

This node integrates with a Neo4j graph database, allowing users to execute Cypher queries and perform various graph-related operations. Specifically, for the Graph Database - Execute Query operation, it enables running arbitrary Cypher queries against a Neo4j instance and retrieving the results.

Common scenarios where this node is beneficial include:

  • Querying complex graph data structures to extract insights or relationships.
  • Running custom Cypher queries to fetch nodes, relationships, or aggregated data.
  • Integrating Neo4j query results into automated workflows for further processing or decision-making.

Practical example:

  • A user wants to find all friends of a particular user in a social network graph stored in Neo4j. They can write a Cypher query like MATCH (u:User {name: "Alice"})-[:FRIEND]->(friend) RETURN friend and use this node to execute it and get the list of friends.

Properties

Name Meaning
Index Name The index name to use; optional string that may specify which index to target.
Cypher Query The Cypher query string to execute on the Neo4j graph database; required for execution.

Output

The output is a JSON array representing the result of the executed Cypher query. Each element corresponds to a record returned by the query, typically an object with keys matching the returned fields or nodes from the query.

For example, if the query returns nodes or relationships, each item in the output array will contain their properties as JSON objects.

The node does not output binary data for this operation.

Dependencies

  • Requires access to a Neo4j database instance.
  • Needs credentials including the Neo4j URI, username, password, and optionally the database name.
  • The node uses the @langchain/community/graphs/neo4j_graph package internally to interact with Neo4j.
  • Proper configuration of the Neo4j API credentials within n8n is necessary.

Troubleshooting

  • Common issues:

    • Invalid Cypher syntax: The query must be valid Cypher; otherwise, Neo4j will return an error.
    • Connection errors: Ensure the Neo4j URI, username, and password are correct and the database is accessible.
    • Empty results: If the query matches no data, the output will be an empty array.
  • Error messages:

    • Errors thrown by the node will generally indicate either connection/authentication failures or Cypher query errors.
    • To resolve, verify credentials, check network connectivity, and validate the Cypher query syntax using Neo4j tools or browser interface.

Links and References

Discussion