Add configurable case-insensitive search #4
Reference in New Issue
Block a user
Delete Branch "feature/case-insensitive-search"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds configurable case-insensitive search to handle Qdrant embedding case sensitivity.
Changes
MEM0_CASE_INSENSITIVE(default: false)Problem
Qdrant shows case sensitivity: "mattermost" search → 57% match, "Mattermost" → 41%
Config
Or in
~/.hermes/mem0-local.json:Trade-off
Doubles API calls when enabled. Disabled by default.
🚨 Critical Logic Error Found
There is a recursion error in the
client.pyfile that will cause the application to crash whencase_insensitive=True.The Issue
In
LocalMem0Client.search, the code callsself._search_with_queryto perform the dual search. However, the method_search_with_queryis defined after the logic insearchthat calls it, but thesearchmethod's logic overwrites the originalsearchmethod's body without preserving the original functionality for the helper.Wait, looking closer at the diff:
searchmethod is modified to handlecase_insensitive.case_insensitiveis True, it callsself._search_with_query._search_with_querymethod is defined after thesearchmethod.searchmethod's original logic (theif not case_insensitiveblock) is fine._search_with_querymethod is defined inside the diff, but let's check the indentation and scope.- The diff shows
- However, look at the
- Now look at the definition of
def _search_with_query(_search_with_querybeing added at the end of the class.searchmethod implementation in the diff:_search_with_query:self,
query: str,
user_id: Optional[str] = None,
limit: int = 5,
) -> List[Dict]:
"""Internal search helper for case-insensitive mode."""
payload = {"query": query, "limit": limit}
if user_id:
payload["user_id"] = user_id
```
_search_with_querymethod in the diff ends abruptly. It constructs thepayloadbut never callsself._requestand never returns the result.searchmethod (before theif not case_insensitiveblock) had the_requestcall. The new helper method is missing this critical line.Impact
When
MEM0_CASE_INSENSITIVE=true:self._search_with_query(...)._search_with_querycreates a payload but returnsNone(implicitly).results_originalandresults_lowerbecomeNone.for result in results_original + results_lower:will raise aTypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'.Fix
You need to add the request and return statement to
_search_with_query.Corrected
client.pysnippet:Minor Observation (Documentation)
In
after-install.md, thecurlcommand indentation is slightly inconsistent in the "Check server connectivity" section:The indentation changed from 3 spaces to 4 spaces. This is a minor formatting issue and won't break functionality, but it's worth noting for consistency.
✅ Summary: The primary blocker is the missing
returnandself._requestcall in the new_search_with_queryhelper method. Without this, the feature will crash.