Skip to content

[BUG] Cannot search tags #240

@sk365

Description

@sk365

Bug Description

I cannot search tags using Basic Memory version: 0.14.2

Please help.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Install version ' 0.14.2' on MacOS 15.5. (Mac Silicon) with brew, run it
  2. Create a note with tag "DrMock"
  3. Search "DrMock" from MCP frontend ( As A frontend I use LibreChat. See Server response below.
  4. No result
  5. Search for note content (nor YAML frontend works fine)
avatar

suche nach #DrMock
4 / 4

**Commencing Search for Hashtag**

I'm initiating the search for "#DrMock" using the `search_notes_ mcp_basic_memory` tool. This seems ideal for querying across all content. My initial step is to input "#DrMock" as the search term, and await the results. I will soon be sifting through the found results.


**Refining the Query Parameters**

I've determined that "#DrMock" will be the explicit search term for the `search_notes_ mcp_basic_memory` tool. This tool appears well-suited to the user's needs for a comprehensive hashtag search. The query is now fully specified.
Agent hat diese Information an basic-memory gesendet

{
  "query": "#DrMock"
}

Ergebnis

Error executing tool search_notes: (sqlite3.OperationalError) fts5: syntax error near "#"
[SQL: 
            SELECT 
                id, 
                title, 
                permalink,
                file_path,
                type,
                metadata,
                from_id,
                to_id,
                relation_type,
                entity_id,
                content_snippet,
                category,
                created_at,
                updated_at,
                bm25(search_index) as score
            FROM search_index 
            WHERE (title MATCH ? OR content_stems MATCH ?)
            ORDER BY score ASC 
            LIMIT ?
            OFFSET ?
        ]
[parameters: ('#DrMock', '#DrMock', 10, 0)]
(Background on this error at: https://sqlalche.me/e/20/e3q8)

**Troubleshooting Search Queries**

I've hit a snag with the search functionality. Attempting to use "#DrMock" as a search term resulted in an FTS5 syntax error, specifically near the '#' character. It seems this character is tripping up the search query. Currently, I'm working on refining the query syntax to accommodate special characters like '#'.


**Fixing the Syntax Error**

I've tested searching for "DrMock" without the '#' and it appears to work correctly. The initial FTS5 error was definitely due to the '#' character. Now, I need to implement a pre-processing step to remove or escape special characters before executing the search query to handle these characters gracefully. This should address the core problem.
Agent hat diese Information an basic-memory gesendet

{
  "query": "DrMock"
}

Ergebnis

{
  "results": [],
  "current_page": 1,
  "page_size": 10
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions