Skip to content

Commit adb1c65

Browse files
committed
Add project to find as suggested.
1 parent 425797a commit adb1c65

File tree

1 file changed

+2
-2
lines changed
  • libs/langchain-mongodb/langchain_mongodb/graphrag

1 file changed

+2
-2
lines changed

libs/langchain-mongodb/langchain_mongodb/graphrag/graph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ def _safe_get(lst: list, i: int, default: Any = "") -> Any:
585585

586586
# First pass: Add all nodes with their attributes
587587
nx_graph = nx.DiGraph(**nx_opts)
588-
for doc in self.collection.find({}):
588+
for doc in self.collection.find({}, {"type": 1, "attributes": 1}):
589589
# Add node with all attributes
590590
node_id = doc["_id"]
591591
node_attrs = {}
@@ -596,7 +596,7 @@ def _safe_get(lst: list, i: int, default: Any = "") -> Any:
596596
nx_graph.add_node(node_id, **node_attrs, **json_opts)
597597

598598
# Second pass: Add edges based on relationships
599-
for doc in self.collection.find({}):
599+
for doc in self.collection.find({}, {"_id": 1, "relationships": 1}):
600600
source_id = doc["_id"]
601601
relationships = doc.get("relationships", {})
602602
# relationships can contain numerous target_ids, each with type and attributes

0 commit comments

Comments
 (0)