Skip to content

Hybrid search can completely exclude document chunks in containers with many memories #1398

Description

@Drewlius

Details

searchMode: "hybrid" is documented as searching both memory entries and document chunks. In practice, hybrid searches against a container with a large memory pool can return only memory entries, even when an explicit documents search returns relevant chunks for the same query.


If this is expected because hybrid performs one global ranking across both result types, the documentation should state that hybrid does not guarantee representation from both sources. It would also be useful to support separate limits or result quotas for memories and document chunks.


Environment

TypeScript SDK: supermemory@4.24.2
Endpoint: POST /v4/search
Search limit: 100
Threshold: 0
Container contains both extracted memories and indexed documents

Reproduction

import Supermemory from "supermemory";

const client = new Supermemory({
  apiKey: process.env.SUPERMEMORY_API_KEY,
});

const query = "a query matching content known to exist in an indexed document";

const hybrid = await client.search({
  q: query,
  containerTag: "USER_CONTAINER",
  searchMode: "hybrid",
  limit: 100,
  threshold: 0,
});

const documents = await client.search({
  q: query,
  containerTag: "USER_CONTAINER",
  searchMode: "documents",
  limit: 100,
  threshold: 0,
});

function countKinds(results) {
  return {
    memories: results.filter((result) => result.memory !== undefined).length,
    chunks: results.filter((result) => result.chunk !== undefined).length,
  };
}

console.log("hybrid", countKinds(hybrid.results));
console.log("documents", countKinds(documents.results));

Actual Results

hybrid:
  total: 100
  memories: 100
  chunks: 0
  score range: 0.691–0.756

documents:
  total: 100
  memories: 0
  chunks: 100
  score range: 0.616–0.681

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