Skip to content

graphify query: punctuation in search terms breaks node matching #978

Description

@Johell1NS

Bug Description

graphify query, graphify path, and graphify explain all fail to match nodes when the search term contains punctuation (e.g. ?, !, ., ,, :).

Root Cause

In serve.py line 309, _query_graph_text tokenizes the question by simply splitting on whitespace:

python terms = [t.lower() for t in question.split() if len(t) > 2]

This means a search for "authentication?" stays as "authentication?" and never matches a node with label "Authentication" or "auth_service".

The same issue affects _find_node (line 328), which is used by graphify path and graphify explain - if the user passes "Authentication?" as an argument, the ? prevents matching.

Example

`�ash
graphify query "how does the authentication work?"

Searches for ["how", "does", "authentication?", "work?"]

"authentication?" never matches node "Authentication" or "auth_service"

Falls back to unrelated nodes matching shorter terms

graphify query "how does the authentication work"

Works correctly - matches "Authentication", "auth_service" nodes

`

Suggested Fix

In serve.py, strip punctuation from each term before matching. Change line 309 from:

python terms = [t.lower() for t in question.split() if len(t) > 2]

to:

python import re terms = [re.sub(r'[^\w\s]', '', t).lower() for t in question.split() if len(t) > 2]

A similar cleanup should be applied in _find_node for the label parameter.

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