Skip to content

[Bug] Fuzzy search in find_code returns no results for close matches #758

@qwertist

Description

@qwertist

Description

codegraph_find_code with fuzzy_search=true and edit_distance=2 returns zero results for queries that differ by just 1 character from an existing function name.

Steps to Reproduce

pip install codegraphcontext==0.3.1
cgc index /path/to/project  # project contains a function named "autoIndex"

Then via MCP:

# Exact search works:
codegraph_find_code(query="autoIndex")
# → returns autoIndex function correctly

# Fuzzy search fails:
codegraph_find_code(query="autoIndx", fuzzy_search=true, edit_distance=2)
# → returns 0 results

Expected Behavior

Fuzzy search with edit_distance=2 should find autoIndex when querying autoIndx (edit distance = 1, well within threshold).

Actual Behavior

{
  "query": "autoindx",
  "functions_by_name": [],
  "classes_by_name": [],
  "variables_by_name": [],
  "content_matches": [],
  "ranked_results": [],
  "total_matches": 0
}

Note: the query is lowercased to autoindx in the response, suggesting the fuzzy search may be operating on a lowercased version while the index stores original case — potentially causing the mismatch.

Environment

  • codegraphcontext: 0.3.1
  • Database backend: KùzuDB (default)
  • Python: 3.12.3
  • OS: Linux (Ubuntu)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions