Skip to content

Latest commit

 

History

History
105 lines (76 loc) · 3.31 KB

File metadata and controls

105 lines (76 loc) · 3.31 KB
title FalkorDBDocumentStore
id falkordbdocumentstore
slug /falkordbdocumentstore
description Use the FalkorDB graph database with Haystack for GraphRAG workloads.

FalkorDBDocumentStore

Use the FalkorDB graph database with Haystack for GraphRAG workloads.

FalkorDB is a high-performance graph database optimized for GraphRAG workloads. The FalkorDBDocumentStore stores documents as graph nodes and supports native vector search — no APOC is required. Documents and their meta fields are stored flat on each node, and all bulk writes use UNWIND + MERGE for safe OpenCypher upserts.

For more information, see the FalkorDB documentation.

Installation

Run FalkorDB with Docker:

docker run -d -p 6379:6379 falkordb/falkordb:latest

Install the Haystack integration:

pip install falkordb-haystack

Usage

Initialize the document store and write documents:

from haystack import Document
from haystack_integrations.document_stores.falkordb import FalkorDBDocumentStore

document_store = FalkorDBDocumentStore(
    host="localhost",
    port=6379,
    embedding_dim=768,
    recreate_graph=True,
)

document_store.write_documents(
    [
        Document(
            content="There are over 7,000 languages spoken around the world today.",
        ),
        Document(
            content="Elephants have been observed to recognize themselves in mirrors.",
        ),
    ],
)
print(document_store.count_documents())

To learn more about the initialization parameters, see the API docs.

To compute real embeddings for your documents, use a Document Embedder such as the SentenceTransformersDocumentEmbedder.

Authentication

To connect to a password-protected FalkorDB instance, pass the password via Secret:

from haystack.utils import Secret
from haystack_integrations.document_stores.falkordb import FalkorDBDocumentStore

document_store = FalkorDBDocumentStore(
    host="localhost",
    port=6379,
    password=Secret.from_env_var("FALKORDB_PASSWORD"),
)

Similarity Functions

FalkorDBDocumentStore supports two similarity functions for vector search:

  • "cosine" (default): cosine similarity, best for normalized embeddings.
  • "euclidean": Euclidean distance, useful when embedding magnitude matters.
document_store = FalkorDBDocumentStore(
    host="localhost",
    port=6379,
    embedding_dim=768,
    similarity="euclidean",
)

Supported Retrievers

  • FalkorDBEmbeddingRetriever: Retrieves documents from the FalkorDBDocumentStore based on vector similarity using FalkorDB's native vector index.
  • FalkorDBCypherRetriever: Retrieves documents by executing arbitrary OpenCypher queries, enabling graph traversal and multi-hop queries for GraphRAG pipelines.