Skip to content

[BUG] Search Methods Configuration Ignored #788

Description

@paveljakov

Bug Description

The search system ignores the configured search_methods and always executes all search methods (BM25, cosine similarity, and BFS) regardless of what is specified in the search configuration.

Steps to Reproduce

Provide a minimal code example that reproduces the issue:

bfs_config = SearchConfig(
    node_config=NodeSearchConfig(
        search_methods=[NodeSearchMethod.bfs],
        bfs_max_depth=1,
        reranker=NodeReranker.node_distance
    ),
    edge_config=EdgeSearchConfig(
        search_methods=[EdgeSearchMethod.bfs],
        bfs_max_depth=1,
        reranker=EdgeReranker.node_distance
    ),
    limit=10
)

results = await self.graphiti.search_(
    query="spare parts",
    center_node_uuid=center_node_uuid,
    bfs_origin_node_uuids=[center_node_uuid],
    config=bfs_config
)

# All three search methods execute despite only BFS being configured

Expected Behavior

Only the search methods specified in config.search_methods should execute. In the example above, only BFS should run since search_methods=[EdgeSearchMethod.bfs].

Actual Behavior

All search methods (BM25 fulltext search, cosine similarity search, and BFS search) always execute regardless of the search_methods configuration. The search configuration is completely ignored.

Environment

  • Graphiti Version: 0.18.1
  • Python Version: 3.13
  • Operating System: macos
  • Database Backend: neo4j
  • LLM Provider & Model: OpenAI GPT-4.1-mini

Installation Method

  • pip install
  • poetry
  • uv add
  • Development installation (git clone)

Error Messages/Traceback

No explicit errors, but performance impact and unexpected behavior due to running unintended search methods.

Configuration

# Any search configuration with selective search methods fails to work as expected
SearchConfig(
    node_config=NodeSearchConfig(
        search_methods=[NodeSearchMethod.bfs], # This gets ignored
        bfs_max_depth=1,
        reranker=NodeReranker.node_distance
    ),
    edge_config=EdgeSearchConfig(
        search_methods=[EdgeSearchMethod.bfs], # This gets ignored
        bfs_max_depth=1,
        reranker=EdgeReranker.node_distance
    )
)

Additional Context

  • This happens consistently across all search configurations
  • Affects both edge_search and node_search functions in graphiti_core/search/search.py
  • The issue is in lines 180-204 (edge_search) and 301-318 (node_search) where all methods are hardcoded in semaphore_gather calls
  • Performance impact: unnecessary search methods consume compute resources and time
  • Which component: core library

Possible Solution

The edge_search and node_search functions should conditionally build the search tasks list based on config.search_methods instead of hardcoding all three search methods in the semaphore_gather call.

Code Fix

Replace the hardcoded search method calls with conditional logic:

# Instead of always running all methods:
search_results = await semaphore_gather(
    edge_fulltext_search(...),      # Always runs
    edge_similarity_search(...),    # Always runs  
    edge_bfs_search(...),          # Always runs
)

# Use conditional execution:
search_tasks = []
if EdgeSearchMethod.bm25 in config.search_methods:
    search_tasks.append(edge_fulltext_search(...))
if EdgeSearchMethod.cosine_similarity in config.search_methods:
    search_tasks.append(edge_similarity_search(...))
if EdgeSearchMethod.bfs in config.search_methods:
    search_tasks.append(edge_bfs_search(...))

search_results = await semaphore_gather(*search_tasks)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions