{"id":8291,"library":"llama-index-vector-stores-neo4jvector","title":"LlamaIndex Neo4j Vector Store","description":"The `llama-index-vector-stores-neo4jvector` library provides an integration for LlamaIndex to use Neo4j as a vector store. It enables storing, indexing, and querying of document embeddings within a Neo4j graph database, supporting operations like vector search, hybrid search, and metadata filtering. The current version is 0.6.0, and it maintains an active development and release cadence within the LlamaIndex ecosystem.","status":"active","version":"0.6.0","language":"en","source_language":"en","source_url":"https://github.com/run-llama/llama_index/tree/main/llama-index-integrations/vector_stores/llama-index-vector-stores-neo4jvector","tags":["LlamaIndex","Neo4j","Vector Store","LLM","RAG","Graph Database"],"install":[{"cmd":"pip install llama-index-vector-stores-neo4jvector llama-index-llms-openai llama-index-embeddings-openai neo4j","lang":"bash","label":"Install core and dependencies"}],"dependencies":[{"reason":"Core LlamaIndex functionalities are required.","package":"llama-index-core","optional":false},{"reason":"Official Neo4j Python driver for database interaction.","package":"neo4j","optional":false},{"reason":"Commonly used LLM provider for embedding generation and query answering.","package":"llama-index-llms-openai","optional":true},{"reason":"Commonly used embedding model provider for vector generation.","package":"llama-index-embeddings-openai","optional":true}],"imports":[{"note":"Following LlamaIndex v0.10+ package refactor, integration packages must be imported directly from their specific paths, not the consolidated `llama_index.vector_stores` namespace.","wrong":"from llama_index.vector_stores import Neo4jVectorStore","symbol":"Neo4jVectorStore","correct":"from llama_index.vector_stores.neo4jvector import Neo4jVectorStore"},{"note":"Post LlamaIndex v0.10, core components are found under `llama_index.core`.","symbol":"VectorStoreIndex","correct":"from llama_index.core import VectorStoreIndex"}],"quickstart":{"code":"import os\nfrom llama_index.vector_stores.neo4jvector import Neo4jVectorStore\nfrom llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings\nfrom llama_index.core.embeddings import resolve_embed_model\n\n# Set environment variables for Neo4j and OpenAI\n# Ensure you have a running Neo4j instance (e.g., Docker, AuraDB)\n# NEO4J_URI = \"bolt://localhost:7687\"\n# NEO4J_USERNAME = \"neo4j\"\n# NEO4J_PASSWORD = \"password\"\n# OPENAI_API_KEY = \"sk-...\"\n\n# Configure LlamaIndex settings (LLM and Embedding Model)\nSettings.embed_model = resolve_embed_model(\"openai\") # Or any other embedding model\n\n# Neo4j connection details\nneo4j_url = os.environ.get(\"NEO4J_URI\", \"bolt://localhost:7687\")\nneo4j_username = os.environ.get(\"NEO4J_USERNAME\", \"neo4j\")\nneo4j_password = os.environ.get(\"NEO4J_PASSWORD\", \"password\")\nembedding_dimension = 1536 # OpenAI's default embedding dimension\n\n# Initialize Neo4jVectorStore\ntry:\n    neo4j_vector_store = Neo4jVectorStore(\n        username=neo4j_username,\n        password=neo4j_password,\n        url=neo4j_url,\n        embedding_dimension=embedding_dimension,\n        index_name=\"vector\",\n        node_label=\"Chunk\",\n        embedding_node_property=\"embedding\",\n        text_node_property=\"text\",\n    )\nexcept ValueError as e:\n    print(f\"Error connecting to Neo4j: {e}. Please ensure Neo4j is running and credentials are correct.\")\n    exit()\n\n# Create a dummy document for demonstration (in a 'data' directory)\n# You might need to create a 'data' directory and a 'test.txt' file\n# e.g., echo \"This is a test document about LlamaIndex and Neo4j integration.\" > data/test.txt\n\n# Load documents\n# Ensure 'data' directory exists and contains documents\ntry:\n    documents = SimpleDirectoryReader(\"data\").load_data()\nexcept Exception as e:\n    print(f\"Error loading documents: {e}. Make sure a 'data' directory exists and contains files.\")\n    documents = []\n\nif not documents:\n    print(\"No documents loaded. Creating a dummy document.\")\n    from llama_index.core.schema import Document\n    documents = [Document(text=\"LlamaIndex integrates with Neo4j to provide a powerful vector store for RAG applications.\")]\n\n# Create a VectorStoreIndex\nindex = VectorStoreIndex.from_documents(documents, vector_store=neo4j_vector_store)\n\n# Query the index\nquery_engine = index.as_query_engine()\nresponse = query_engine.query(\"What is LlamaIndex?\")\nprint(response)\n\n# Example of retrieving documents directly (without LLM synthesis)\nretriever = index.as_retriever(similarity_top_k=2)\nnodes = retriever.retrieve(\"How does LlamaIndex work with Neo4j?\")\nfor node in nodes:\n    print(f\"Retrieved Node: {node.text[:100]}...\")\n\n# Clean up (optional, depends on your use case)\n# neo4j_vector_store._driver.close()","lang":"python","description":"This quickstart demonstrates how to set up `Neo4jVectorStore` with LlamaIndex. It initializes the vector store with Neo4j connection details, loads sample documents, creates a `VectorStoreIndex`, and then performs a query. It assumes Neo4j credentials and OpenAI API key are set as environment variables and that a 'data' directory exists for document loading."},"warnings":[{"fix":"Install the specific integration package (`pip install llama-index-vector-stores-neo4jvector`) and update imports to `from llama_index.vector_stores.neo4jvector import Neo4jVectorStore`. Core components now reside under `llama_index.core`.","message":"LlamaIndex v0.10+ introduced a major package refactor. All integrations, including Neo4jVectorStore, are now standalone PyPI packages. Direct imports from `llama_index.vector_stores` are no longer valid for integration classes.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Ensure the `embedding_dimension` parameter passed to `Neo4jVectorStore` precisely matches the dimension of the embedding model you are using and the dimension of any existing vector indexes in Neo4j. If dimensions differ, you may need to recreate the vector index in Neo4j or re-index your data.","message":"Mismatch between `embedding_dimension` specified in `Neo4jVectorStore` and the actual dimension of indexed vectors in the Neo4j database will cause query failures (e.g., `java.lang.IllegalArgumentException: Index query vector has X dimensions, but indexed vectors have Y.`).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade your Neo4j database instance to a version that supports vector indexing (e.g., Neo4j 5.5+). Refer to the official Neo4j documentation for specific version requirements and upgrade paths.","message":"Creating vector indexes in Neo4j requires a Neo4j database version that supports vector index capabilities (e.g., Neo4j 5.5 or later). Using older versions may result in `Invalid input 'VECTOR'` or similar Cypher errors when the store attempts to create an index.","severity":"gotcha","affected_versions":"All versions with older Neo4j databases"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install the specific integration package: `pip install llama-index-vector-stores-neo4jvector`. Then, update the import statement to `from llama_index.vector_stores.neo4jvector import Neo4jVectorStore`.","cause":"Attempting to import `Neo4jVectorStore` (or other vector stores) from `llama_index.vector_stores` instead of the dedicated integration package path after LlamaIndex v0.10+ refactor.","error":"ModuleNotFoundError: No module named 'llama_index.vector_stores'"},{"fix":"Verify that `embedding_dimension` parameter in `Neo4jVectorStore` matches your embedding model's output dimension. If an index already exists, ensure its dimension is consistent or recreate the Neo4j vector index with the correct `embedding_dimension`.","cause":"The `embedding_dimension` configured in `Neo4jVectorStore` does not match the actual dimension of the vectors stored in the Neo4j vector index, or the embedding model used for querying generates vectors of a different dimension.","error":"neo4j.exceptions.ClientError: {code: Neo.ClientError.Procedure.ProcedureCallFailed} {message: Failed to invoke procedure `db.index.vector.queryNodes`: Caused by: java.lang.IllegalArgumentException: Index query vector has X dimensions, but indexed vectors have Y.}"},{"fix":"Double-check `NEO4J_URI`, `NEO4J_USERNAME`, and `NEO4J_PASSWORD` environment variables or constructor arguments. Ensure the Neo4j instance is running and network accessible (e.g., `bolt://localhost:7687`).","cause":"Incorrect Neo4j URI, username, password, or the Neo4j database instance is not running or accessible from the application.","error":"ValueError: Could not connect to Neo4j database. Ensure the URL and credentials are correct and the database is running."}]}