fix(falkordb): short-circuit fulltext query when every token was a stopword#1590
Open
aasc77 wants to merge 2 commits into
Open
fix(falkordb): short-circuit fulltext query when every token was a stopword#1590aasc77 wants to merge 2 commits into
aasc77 wants to merge 2 commits into
Conversation
…opword
`_build_falkor_fulltext_query` (and the equivalent class-method
`FalkorDriver.build_fulltext_query`) currently emits
`(@group_id:"X") ()` whenever the input's content tokens reduce to all
stopwords after sanitize + filter — FalkorDB/RediSearch rejects the
trailing empty group with `Syntax error at offset N near X`. There's a
too-long guard above the wrap site but no symmetric too-short/empty one.
Every call site of `_build_falkor_fulltext_query` already special-cases a
`''` return as "no candidates":
fuzzy_query = _build_falkor_fulltext_query(query, group_ids)
if fuzzy_query == '':
return []
So the fix is a one-line early return after the stopword filter — same
sentinel the too-long path already uses, no caller-side change needed.
Hit during a 230-episode bulk replay against a 1849-entity FalkorDB graph:
the dedup queue stalled at ~31% when an episode's LLM-derived content
tokens happened to be all stopwords. With this guard, the rest of the
replay completed cleanly.
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA behalf on myself, e-mail: angel.s@me.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_build_falkor_fulltext_query(and the equivalent class-methodFalkorDriver.build_fulltext_query) emit(@group_id:"X") ()whenever the input's content tokens reduce to all stopwords after sanitize + filter — FalkorDB/RediSearch rejects the trailing empty group withSyntax error at offset N near X. There's a too-long guard above the wrap site but no symmetric too-short/empty one. This PR adds it.Every call site already special-cases the
''return as "no candidates" (if fuzzy_query == '': return []innode_fulltext_search/edge_fulltext_search/ the community siblings), so no caller-side change is required — the new guard piggybacks on the existing sentinel.How I hit it
During a 230-episode bulk replay against a 1849-entity FalkorDB graph, the dedup queue stalled at 31% when an episode's LLM-derived content tokens happened to be all stopwords. Container log (graphiti-core 0.28.2 + FalkorDB v4.18.10):
Reproducing the parse error directly against FalkorDB:
With this PR applied the replay completed cleanly.
Test plan
''as "no candidates" — verified by grep acrossgraphiti_core/driver/falkordb/operations/search_ops.py(4 sites:node_fulltext_search,edge_fulltext_search, community node + edge siblings).()output was never a valid RediSearch expression so any caller that did something with it was broken anyway.Happy to add a unit test directly inside this repo if a maintainer points me at the right place — I can see the testing structure under
tests/and would just want to confirm the location/style conventions.Notes
graphiti_core/driver/falkordb_driver.py(class-method form onFalkorDriver.build_fulltext_query) andgraphiti_core/driver/falkordb/operations/search_ops.py(module-level_build_falkor_fulltext_query). Same guard, same comment, applied to both.'').