# graphiti-core Patches — FalkorDB Vector Index Support

Vendored patches against graphiti-core 0.29.0 adding native FalkorDB
vector index support. Three files modified, all under
`graphiti_core/driver/falkordb/` and `graphiti_core/graph_queries.py`.
No changes to Neo4j or Kuzu code paths.

## Why this exists

graphiti-core's FalkorDB driver uses interpreted Cypher cosine math
(`vec.cosineDistance(...)`) for similarity search. Each query becomes a
full table scan over Entity/RELATES_TO/Community nodes. At ~4,000+
entities, single-episode ingest's resolve-against-existing-graph step
takes 8+ minutes and bulk ingest hangs FalkorDB. FalkorDB itself
supports `db.idx.vector.queryNodes` and `db.idx.vector.queryRelationships`
procedures backed by HNSW indexes; graphiti-core's driver doesn't use
them.

These patches:

1. Add `get_vector_indices()` to `graph_queries.py` returning CREATE
   VECTOR INDEX statements for FalkorDB on Entity.name_embedding,
   RELATES_TO.fact_embedding, and Community.name_embedding.
2. Extend `falkordb_driver.py:build_indices_and_constraints()` to create
   the vector indexes alongside range and fulltext indexes.
3. Rewrite the three vector-similarity call sites in
   `falkordb/operations/search_ops.py` to use
   `db.idx.vector.queryNodes` and `db.idx.vector.queryRelationships`
   instead of full-scan cosine math. Over-fetches by a configurable
   multiplier to handle filter rejections.

## Files

| Patched file | Source |
|---|---|
| `graphiti_core/graph_queries.py` | Adds `get_vector_indices()` |
| `graphiti_core/driver/falkordb/falkordb_driver.py` | Extends `build_indices_and_constraints` |
| `graphiti_core/driver/falkordb/operations/search_ops.py` | Three query rewrites |

## How to apply

`./apply.sh` — backs up the originals into `./backups/<timestamp>/`
and copies the patched files over.

## How to revert

Move the timestamped backup back over the venv:

    cp backups/<ts>/graph_queries.py /home/aaron/aaronai/venv/lib/python3.12/site-packages/graphiti_core/graph_queries.py
    # ...etc

## Upstream candidate

Documented gap (issue #1263 references it indirectly via vector store
overlay RFC). Maintainers' attention is on Milvus/external vector DB
overlay; this patch is the FalkorDB-native alternative for users who
don't want a separate vector DB. Consider PR after empirical validation
in production.
