Skip to content

Hybrid search never reaches Elasticsearch: search reads engram_memories_default while indexing writes engram_memories_<accountId> #330

Open

Description

@uknwmyname-sudo

Summary

On a self-hosted instance the BM25 half of hybrid search never returns anything. The service detects this, sets hybrid_degraded=true, and continues silently on vectors only.

What happens

src/search/elasticsearch.service.ts resolves the index name in one place (around lines 141–143):

return `engram_memories_${safe}`;   // when the account id is known
...
return 'engram_memories_default';   // fallback

Indexing calls this with the account id and creates engram_memories_<accountId>. The search path calls it without one and queries engram_memories_default, which never exists. The index template is registered for the pattern engram_memories_*, so nothing fails at index-creation time — the mismatch only surfaces at query time:

[HybridSearch] ES keyword search failed (hybrid_degraded=true), returning empty: index_not_found_exception
        index_not_found_exception: no such index [engram_memories_default]

Reproduce

  1. Self-hosted install, store a few memories.
  2. GET _cat/indices on the Elasticsearch container → engram_memories_<accountId> exists and has documents.
  3. Issue any recall. Container log shows index_not_found_exception for engram_memories_default.

Workaround

Creating an alias restores keyword search without touching the code:

PUT /engram_memories_<accountId>/_alias/engram_memories_default

After that the log shows [HybridSearch] ES keyword search: N results instead of the exception. This is only correct while a single account exists on the instance.

Suggested fix

Pass the account id through to the search path, or resolve the index name from the authenticated context in both paths. Also consider treating hybrid_degraded=true as a condition worth surfacing in /v1/health rather than only in logs — a degraded hybrid search is indistinguishable from a working one from the client side.


Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions