Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions backend/app/database/falkor/code-graph-backend/api/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .entities import *
from typing import Optional
from falkordb import FalkorDB, Path, Node, QueryResult
from redis.exceptions import ResponseError

# Configure the logger
import logging
Expand Down Expand Up @@ -48,18 +49,23 @@ def __init__(self, name: str) -> None:
self.backlog = None

# create indicies

# index File path, name and ext fields
try:
self.g.create_node_range_index("File", "name", "ext")
except Exception:
pass

# index Function using full-text search
self._safe_create_index(self.g.create_node_range_index, "File", "name", "ext")
self._safe_create_index(self.g.create_node_fulltext_index, "Searchable", "name")
# index File path, name and ext fields
def _safe_create_index(self, func, label, *args):
"""Safely create an index, handling 'already exists' gracefully."""
try:
self.g.create_node_fulltext_index("Searchable", "name")
except Exception:
pass
func(label, *args)
logging.debug(f"Successfully created/verified index for '{label}'.")
except ResponseError as e: # Catch specific DB response errors
if "already exists" in str(e).lower():
logging.info(f"Index for '{label}' already exists.")
else:
logging.error(f"Database error creating index for '{label}': {e}", exc_info=True)
raise # Propagate unexpected database errors
except Exception as e: # Catch other unexpected system errors
logging.error(f"Critical system failure during index creation for '{label}': {e}", exc_info=True)
raise

def clone(self, clone: str) -> "Graph":
"""
Expand Down