Neo4j icon

Neo4j

Work with Neo4j database

Overview

This node integrates with a Neo4j database to perform operations on vector stores and graph databases. Specifically, for the Vector Store resource with the Similarity Search operation, it enables searching for vectors similar to a given query text within an existing vector index stored in Neo4j.

Common scenarios include:

  • Finding documents or data points semantically similar to a user query by leveraging vector embeddings.
  • Enhancing search functionality in applications by retrieving nearest neighbors based on vector similarity.
  • Filtering results by metadata properties to narrow down search contextually.

For example, you could use this node to find the top 4 most relevant documents related to a customer support query by embedding the query text and searching the vector store for closest matches.

Properties

Name Meaning
Index Name The name of the vector index to use for similarity search (default: "vector").
Query Text The text input to search for similar vectors in the vector store.
Options Additional options for the similarity search:
- Distance Metric The metric used to measure similarity between vectors. Options: Cosine, Euclidean, Max Inner Product, Dot Product, Jaccard. Default is Cosine.
- Metadata Filter A JSON object to filter the search results by specific metadata properties.
- Retrieval Query A Cypher query string that can be executed as part of the retrieval process (optional).

Output

The output is a JSON array where each element represents a matched vector/document with the following structure:

  • content: The main textual content of the matched document or vector.
  • score: The similarity score between the query vector and the matched vector (lower or higher depending on distance metric).
  • Additional metadata fields included in the original vector's metadata.

No binary data output is produced by this operation.

Example output JSON snippet:

[
  {
    "content": "Matched document text here",
    "score": 0.123,
    "metadataKey1": "value1",
    "metadataKey2": "value2"
  },
  ...
]

Dependencies

  • Requires a Neo4j database instance accessible via credentials including URI, username, password, and database name.
  • Needs an API key credential or authentication token configured in n8n to connect securely to Neo4j.
  • Uses vector embeddings provided as input from a connected AI embedding node.
  • Relies on the @langchain/community/vectorstores/neo4j_vector package for vector store operations.

Troubleshooting

  • Error connecting to Neo4j: Verify that the Neo4j credentials (URI, username, password, database) are correct and that the database is reachable from the n8n environment.
  • Invalid JSON in Metadata Filter: Ensure the metadata filter property contains valid JSON syntax; otherwise, parsing will fail.
  • No embeddings provided: The node expects an embedding input connection when performing similarity search. Make sure an AI embedding node is connected and providing embeddings.
  • Empty or no results returned: Check if the query text is meaningful and that the vector index contains data. Also verify that any metadata filters applied do not exclude all results.
  • Unsupported distance metric: Use one of the supported distance metrics listed in the options; unsupported values may cause errors.

Links and References

Discussion