You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Neo4j in shared-database multi-tenant mode (use_multi_db=False), search_by_embedding returns empty results for specific users even though their data exists in the database.
Root Cause
Post-filter problem: db.index.vector.queryNodes(k, embedding) returns the global top-k most similar nodes, then WHERE clauses (user_name, memory_type, status) filter them further. In a shared database with many users, the target user's nodes are often excluded from the initial top-k, yielding 0 results after filtering.
sources KeyError: metadata["sources"] is accessed without .get() in multiple locations in neo4j.py and neo4j_community.py. When metadata is serialized with model_dump(exclude_none=True) and sources is None, the key is absent, causing a KeyError.
_parse_node deserialization bug: The sources JSON deserialization check node["sources"][idx][0] == "}" should be node["sources"][idx][-1] == "}" (last char, not first), making json.loads never execute.
neo4j_community.pyadd_node crashes on missing embedding: raise ValueError when embedding is None, but some memory types (e.g., UserMemory) may not have embeddings.
Expected Behavior
Vector search should return correct results for any user in a shared database, regardless of how many other users' data exists.
Adding nodes without sources or embedding should not crash.
Environment
Neo4j >= 5.18 (required for vector.similarity.cosine() pre-filtering)
Hi, I'm Luca Garulli, creator of ArcadeDB, and wanted to flag something that might help here.
The root cause you've identified is a known architectural limitation of Neo4j's db.index.vector.queryNodes: it operates on the full graph and returns global top-k candidates before any WHERE predicates are applied, which is why per-tenant filtering collapses results to zero for users with few nodes.
ArcadeDB is an Apache 2.0 multi-model database that is Bolt-compatible (same protocol as Neo4j), so it works with existing Python Neo4j driver code without rewriting your query layer. The key difference: ArcadeDB's vector index supports filtered ANN, predicates like user_name, memory_type, and status are pushed into the index scan rather than applied after retrieval. That means per-tenant queries return accurate results regardless of how sparse the user's data is.
Beyond this specific bug, ArcadeDB also handles Map-type property values natively (relevant to issue #1122) and runs as a single lightweight process or fully embedded: no separate container required.
Happy to help with a quick integration test or point you to a working LightRAG/Graphiti adapter that uses ArcadeDB as a drop-in Neo4j replacement if that would be useful.
Summary: Fixes issue #1360 by removing a leftover regression in the Neo4j sources serialization path. PR #1359 had already addressed the four root causes listed in the issue (post-filter rewrite, sources KeyError guard, _parse_node bracket check, missing-embedding warn-instead-of-raise), but a close re-read showed sources were still being double-encoded: _prepare_node_metadata JSON-dumps each element once, and then add_node / add_nodes_batch in neo4j.py plus add_node in neo4j_community.py repeated the same json.dumps step. The resulting values came back from Neo4j with a leading " instead of {, so _parse_node's [0] == "{" guard skipped json.loads and callers received escaped JSON strings instead of dicts — the exact deserialization-skip symptom listed as bug #3 of the original issue, just one layer upstream.
The change removes the redundant serialization at all three sites, leaving the single canonical encode inside _prepare_node_metadata (matching the already-correct pattern in import_graph and neo4j_community.add_nodes_batch). Existing rows written with the double-encoded value remain readable as escaped strings (no new exception), and new writes round-trip correctly.
Tests: added TestSourcesDoubleSerializationRegression to tests/graph_dbs/test_neo4j_vector_search.py with three cases — add_node single-encode invariant, add_nodes_batch single-encode invariant, and full add_node → _parse_node round-trip. Results: python3 -m pytest tests/graph_dbs/ → 32 passed / 3 skipped (skipped cases are live-Neo4j 5.18+ integration tests). ruff check and ruff format --check are clean on all three touched files.
Activity
lvca commentedon Apr 5, 2026
Hi, I'm Luca Garulli, creator of ArcadeDB, and wanted to flag something that might help here.
The root cause you've identified is a known architectural limitation of Neo4j's
db.index.vector.queryNodes: it operates on the full graph and returns global top-k candidates before any WHERE predicates are applied, which is why per-tenant filtering collapses results to zero for users with few nodes.ArcadeDB is an Apache 2.0 multi-model database that is Bolt-compatible (same protocol as Neo4j), so it works with existing Python Neo4j driver code without rewriting your query layer. The key difference: ArcadeDB's vector index supports filtered ANN, predicates like
user_name,memory_type, andstatusare pushed into the index scan rather than applied after retrieval. That means per-tenant queries return accurate results regardless of how sparse the user's data is.Beyond this specific bug, ArcadeDB also handles Map-type property values natively (relevant to issue #1122) and runs as a single lightweight process or fully embedded: no separate container required.
Happy to help with a quick integration test or point you to a working LightRAG/Graphiti adapter that uses ArcadeDB as a drop-in Neo4j replacement if that would be useful.
Memtensor-AI commentedon Jun 29, 2026
🤖 AutoDev has picked up this issue and started working on it.
Task ID:
cca6c0d25ac3db4eWorking branch:
bugfix/autodev-1360Target branch:
latest dev* branchWorkflow: opsp (analysis → coding → testing → PR)
I will post the PR link here once done. If I need more information, I will ask in the comments.
fix(graph_dbs): stop double-serializing Neo4j sources metadata
Memtensor-AI commentedon Jun 29, 2026
✅ AutoDev task
cca6c0d25ac3db4ecompleted.Summary: Fixes issue #1360 by removing a leftover regression in the Neo4j sources serialization path. PR #1359 had already addressed the four root causes listed in the issue (post-filter rewrite, sources KeyError guard, _parse_node bracket check, missing-embedding warn-instead-of-raise), but a close re-read showed sources were still being double-encoded:
_prepare_node_metadataJSON-dumps each element once, and thenadd_node/add_nodes_batchinneo4j.pyplusadd_nodeinneo4j_community.pyrepeated the same json.dumps step. The resulting values came back from Neo4j with a leading"instead of{, so_parse_node's[0] == "{"guard skippedjson.loadsand callers received escaped JSON strings instead of dicts — the exact deserialization-skip symptom listed as bug #3 of the original issue, just one layer upstream.The change removes the redundant serialization at all three sites, leaving the single canonical encode inside
_prepare_node_metadata(matching the already-correct pattern inimport_graphandneo4j_community.add_nodes_batch). Existing rows written with the double-encoded value remain readable as escaped strings (no new exception), and new writes round-trip correctly.Tests: added
TestSourcesDoubleSerializationRegressiontotests/graph_dbs/test_neo4j_vector_search.pywith three cases —add_nodesingle-encode invariant,add_nodes_batchsingle-encode invariant, and fulladd_node → _parse_noderound-trip. Results:python3 -m pytest tests/graph_dbs/→ 32 passed / 3 skipped (skipped cases are live-Neo4j 5.18+ integration tests).ruff checkandruff format --checkare clean on all three touched files.Base branch:
mainBranch:
bugfix/autodev-1360Commit:
2603999PR: #1974
Assigned to: @MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller
Reviewers: @MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller
Memtensor-AI commentedon Jul 13, 2026
Resolved by #1359. The merged fix is already included in main and released in v2.0.23, so closing this issue as completed.